| Index: chrome/android/javatests/src/org/chromium/chrome/browser/searchwidget/SearchWidgetProviderTest.java
|
| diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/searchwidget/SearchWidgetProviderTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/searchwidget/SearchWidgetProviderTest.java
|
| index 18161df64dbf61abc14de17801b43e8b01cb106f..c7f970fbf6d8264cfd12afaff37eebd9623f676e 100644
|
| --- a/chrome/android/javatests/src/org/chromium/chrome/browser/searchwidget/SearchWidgetProviderTest.java
|
| +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/searchwidget/SearchWidgetProviderTest.java
|
| @@ -28,6 +28,7 @@ import org.chromium.chrome.R;
|
| import org.chromium.chrome.browser.ChromeSwitches;
|
| import org.chromium.chrome.browser.firstrun.FirstRunActivity;
|
| import org.chromium.chrome.browser.util.IntentUtils;
|
| +import org.chromium.chrome.test.util.ApplicationTestUtils;
|
| import org.chromium.content.browser.test.util.CriteriaHelper;
|
|
|
| import java.util.ArrayList;
|
| @@ -89,6 +90,7 @@ public class SearchWidgetProviderTest extends InstrumentationTestCase {
|
| @Override
|
| public void setUp() throws Exception {
|
| super.setUp();
|
| + ApplicationTestUtils.setUp(getInstrumentation().getTargetContext(), true);
|
| SearchActivity.disableForTests();
|
|
|
| mContext = new TestContext();
|
| @@ -96,6 +98,12 @@ public class SearchWidgetProviderTest extends InstrumentationTestCase {
|
| SearchWidgetProvider.setDelegateForTest(mDelegate);
|
| }
|
|
|
| + @Override
|
| + public void tearDown() throws Exception {
|
| + ApplicationTestUtils.tearDown(getInstrumentation().getTargetContext());
|
| + super.tearDown();
|
| + }
|
| +
|
| @SmallTest
|
| public void testUpdateAll() {
|
| SearchWidgetProvider.handleAction(
|
| @@ -121,6 +129,36 @@ public class SearchWidgetProviderTest extends InstrumentationTestCase {
|
| checkWidgetStates(TEXT_SEARCH_ENGINE_FULL, View.VISIBLE);
|
| }
|
|
|
| + @SmallTest
|
| + @CommandLineFlags.Remove(ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE)
|
| + public void testUpdateCachedEngineNameBeforeFirstRun() {
|
| + assertFalse(SearchWidgetProvider.shouldShowFullString());
|
| + SearchWidgetProvider.handleAction(
|
| + new Intent(SearchWidgetProvider.ACTION_UPDATE_ALL_WIDGETS));
|
| +
|
| + // Without any idea of what the default search engine is, widgets should default to saying
|
| + // just "Search".
|
| + checkWidgetStates(TEXT_GENERIC, View.VISIBLE);
|
| +
|
| + // Until First Run is complete, no search engine branding should be displayed. Widgets are
|
| + // already displaying the generic string, and should continue doing so, so they don't get
|
| + // updated.
|
| + mDelegate.mViews.clear();
|
| + SearchWidgetProvider.updateCachedEngineName(TEXT_SEARCH_ENGINE);
|
| + assertEquals(0, mDelegate.mViews.size());
|
| +
|
| + // Manually set the preference, then update the cached engine name again. The
|
| + // SearchWidgetProvider should now believe that its widgets are displaying branding when it
|
| + // isn't allowed to, then update them.
|
| + mDelegate.mViews.clear();
|
| + mDelegate.getSharedPreferences()
|
| + .edit()
|
| + .putString(SearchWidgetProvider.PREF_SEARCH_ENGINE_SHORTNAME, TEXT_SEARCH_ENGINE)
|
| + .apply();
|
| + SearchWidgetProvider.updateCachedEngineName(TEXT_SEARCH_ENGINE);
|
| + checkWidgetStates(TEXT_GENERIC, View.VISIBLE);
|
| + }
|
| +
|
| private void checkWidgetStates(final String expectedString, final int expectedMicrophoneState) {
|
| // Confirm that all the widgets got updated.
|
| Assert.assertEquals(TestDelegate.ALL_IDS.length, mDelegate.mViews.size());
|
|
|