diff options
author | Maurice Lam <yukl@google.com> | 2015-03-27 23:29:54 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2015-03-27 23:29:54 +0000 |
commit | 5e9b02ef72403231363d697dc0f71d398bac350d (patch) | |
tree | 7e97f66438293146bdbeef7893676f62240c058b /library/test/src/com/android/setupwizardlib | |
parent | 4c4303ff1ca811ce0e3eb8ce534c3dd0c8541370 (diff) | |
parent | 9f9367672191190f903955d09a4314d40869acc6 (diff) | |
download | android_frameworks_opt_setupwizard-5e9b02ef72403231363d697dc0f71d398bac350d.tar.gz android_frameworks_opt_setupwizard-5e9b02ef72403231363d697dc0f71d398bac350d.tar.bz2 android_frameworks_opt_setupwizard-5e9b02ef72403231363d697dc0f71d398bac350d.zip |
am 9f936767: [SetupWizardLib] Eclair compat build
* commit '9f9367672191190f903955d09a4314d40869acc6':
[SetupWizardLib] Eclair compat build
Diffstat (limited to 'library/test/src/com/android/setupwizardlib')
-rw-r--r-- | library/test/src/com/android/setupwizardlib/test/SetupWizardLayoutTests.java | 14 | ||||
-rw-r--r-- | library/test/src/com/android/setupwizardlib/test/SystemBarHelperTest.java | 65 |
2 files changed, 49 insertions, 30 deletions
diff --git a/library/test/src/com/android/setupwizardlib/test/SetupWizardLayoutTests.java b/library/test/src/com/android/setupwizardlib/test/SetupWizardLayoutTests.java index f5cd287..cce2f70 100644 --- a/library/test/src/com/android/setupwizardlib/test/SetupWizardLayoutTests.java +++ b/library/test/src/com/android/setupwizardlib/test/SetupWizardLayoutTests.java @@ -16,11 +16,9 @@ package com.android.setupwizardlib.test; -import android.annotation.TargetApi; import android.content.Context; import android.graphics.Color; import android.graphics.drawable.ColorDrawable; -import android.os.Build.VERSION_CODES; import android.test.InstrumentationTestCase; import android.test.suitebuilder.annotation.SmallTest; import android.view.ContextThemeWrapper; @@ -56,16 +54,14 @@ public class SetupWizardLayoutTests extends InstrumentationTestCase { assertEquals("Header text should be \"Abracadabra\"", "Abracadabra", title.getText()); } - @TargetApi(VERSION_CODES.JELLY_BEAN_MR1) @SmallTest public void testAddView() { SetupWizardLayout layout = new SetupWizardLayout(mContext); TextView tv = new TextView(mContext); - int id = View.generateViewId(); - tv.setId(id); + tv.setId(R.id.test_view_id); layout.addView(tv); assertDefaultTemplateInflated(layout); - View view = layout.findViewById(id); + View view = layout.findViewById(R.id.test_view_id); assertSame("The view added should be the same text view", tv, view); } @@ -78,7 +74,6 @@ public class SetupWizardLayoutTests extends InstrumentationTestCase { assertTrue("@id/test_content should be a TextView", content instanceof TextView); } - @TargetApi(VERSION_CODES.JELLY_BEAN_MR1) @SmallTest public void testCustomTemplate() { SetupWizardLayout layout = new SetupWizardLayout(mContext, R.layout.test_template); @@ -86,13 +81,12 @@ public class SetupWizardLayoutTests extends InstrumentationTestCase { assertNotNull("@id/test_template_view should exist in template", templateView); TextView tv = new TextView(mContext); - int id = View.generateViewId(); - tv.setId(id); + tv.setId(R.id.test_view_id); layout.addView(tv); templateView = layout.findViewById(R.id.test_template_view); assertNotNull("@id/test_template_view should exist in template", templateView); - View contentView = layout.findViewById(id); + View contentView = layout.findViewById(R.id.test_view_id); assertSame("The view added should be the same text view", tv, contentView); // The following methods should be no-ops because the custom template doesn't contain the diff --git a/library/test/src/com/android/setupwizardlib/test/SystemBarHelperTest.java b/library/test/src/com/android/setupwizardlib/test/SystemBarHelperTest.java index c364984..98e3f73 100644 --- a/library/test/src/com/android/setupwizardlib/test/SystemBarHelperTest.java +++ b/library/test/src/com/android/setupwizardlib/test/SystemBarHelperTest.java @@ -21,6 +21,8 @@ import android.content.Context; import android.content.res.Configuration; import android.graphics.drawable.Drawable; import android.net.Uri; +import android.os.Build.VERSION; +import android.os.Build.VERSION_CODES; import android.os.Bundle; import android.test.AndroidTestCase; import android.test.suitebuilder.annotation.SmallTest; @@ -51,71 +53,94 @@ public class SystemBarHelperTest extends AndroidTestCase { public void testAddVisibilityFlagView() { final View view = createViewWithSystemUiVisibility(0x456); SystemBarHelper.addVisibilityFlag(view, 0x1400); - assertEquals("View visibility should be 0x1456", 0x1456, view.getSystemUiVisibility()); + if (VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB) { + // Check that result is 0x1456, because 0x1400 | 0x456 = 0x1456. + assertEquals("View visibility should be 0x1456", 0x1456, view.getSystemUiVisibility()); + } } @SmallTest public void testRemoveVisibilityFlagView() { final View view = createViewWithSystemUiVisibility(0x456); SystemBarHelper.removeVisibilityFlag(view, 0x1400); - assertEquals("View visibility should be 0x56", 0x56, view.getSystemUiVisibility()); + if (VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB) { + // Check that result is 0x56, because 0x456 & ~0x1400 = 0x56. + assertEquals("View visibility should be 0x56", 0x56, view.getSystemUiVisibility()); + } } @SmallTest public void testAddVisibilityFlagWindow() { final Window window = createWindowWithSystemUiVisibility(0x456); SystemBarHelper.addVisibilityFlag(window, 0x1400); - assertEquals("View visibility should be 0x1456", 0x1456, - window.getAttributes().systemUiVisibility); + if (VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB) { + // Check that result is 0x1456 = 0x1400 | 0x456. + assertEquals("View visibility should be 0x1456", 0x1456, + window.getAttributes().systemUiVisibility); + } } @SmallTest public void testRemoveVisibilityFlagWindow() { final Window window = createWindowWithSystemUiVisibility(0x456); SystemBarHelper.removeVisibilityFlag(window, 0x1400); - assertEquals("View visibility should be 0x56", 0x56, - window.getAttributes().systemUiVisibility); + if (VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB) { + // Check that result is 0x56 = 0x456 & ~0x1400. + assertEquals("View visibility should be 0x56", 0x56, + window.getAttributes().systemUiVisibility); + } } @SmallTest public void testHideSystemBarsWindow() { final Window window = createWindowWithSystemUiVisibility(0x456); SystemBarHelper.hideSystemBars(window); - assertEquals("DEFAULT_IMMERSIVE_FLAGS should be added to window's systemUiVisibility", - DEFAULT_IMMERSIVE_FLAGS | 0x456, - window.getAttributes().systemUiVisibility); - assertEquals("DEFAULT_IMMERSIVE_FLAGS should be added to decorView's systemUiVisibility", - DEFAULT_IMMERSIVE_FLAGS | 0x456, - window.getDecorView().getSystemUiVisibility()); + if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) { + assertEquals("DEFAULT_IMMERSIVE_FLAGS should be added to window's systemUiVisibility", + DEFAULT_IMMERSIVE_FLAGS | 0x456, + window.getAttributes().systemUiVisibility); + assertEquals( + "DEFAULT_IMMERSIVE_FLAGS should be added to decorView's systemUiVisibility", + DEFAULT_IMMERSIVE_FLAGS | 0x456, + window.getDecorView().getSystemUiVisibility()); + } } @SmallTest public void testSetBackButtonVisibleTrue() { final Window window = createWindowWithSystemUiVisibility(0x456); SystemBarHelper.setBackButtonVisible(window, true); - assertEquals("View visibility should be 0x456", 0x456, - window.getAttributes().systemUiVisibility); + if (VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB) { + assertEquals("View visibility should be 0x456", 0x456, + window.getAttributes().systemUiVisibility); + } } @SmallTest public void testSetBackButtonVisibleFalse() { final Window window = createWindowWithSystemUiVisibility(0x456); SystemBarHelper.setBackButtonVisible(window, false); - assertEquals("STATUS_BAR_DISABLE_BACK should be added to systemUiVisibility", - 0x456 | STATUS_BAR_DISABLE_BACK, window.getAttributes().systemUiVisibility); + if (VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB) { + assertEquals("STATUS_BAR_DISABLE_BACK should be added to systemUiVisibility", + 0x456 | STATUS_BAR_DISABLE_BACK, window.getAttributes().systemUiVisibility); + } } private View createViewWithSystemUiVisibility(int vis) { final View view = new View(getContext()); - view.setSystemUiVisibility(vis); + if (VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB) { + view.setSystemUiVisibility(vis); + } return view; } private Window createWindowWithSystemUiVisibility(int vis) { final Window window = new TestWindow(getContext(), createViewWithSystemUiVisibility(vis)); - WindowManager.LayoutParams attrs = window.getAttributes(); - attrs.systemUiVisibility = vis; - window.setAttributes(attrs); + if (VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB) { + WindowManager.LayoutParams attrs = window.getAttributes(); + attrs.systemUiVisibility = vis; + window.setAttributes(attrs); + } return window; } |