Commit 9330d613 authored by Troy Hildebrandt's avatar Troy Hildebrandt Committed by Commit Bot

Fix NewApi Lint errors for browser/locale tests.

NewApi warnings were suppressed accidentally and an AssertionError
constructor that requires API 19 was used. The NewApi warning are back,
so this fix avoids using the AssertionError, and throws the exceptions
as they are.

R=tedchoc@chromium.org

Bug: 805509,803484
Change-Id: I35723261c6d72bdac08d0236dbb8e46d752e0bfb
Reviewed-on: https://chromium-review.googlesource.com/883566Reviewed-by: default avatarTed Choc <tedchoc@chromium.org>
Commit-Queue: Troy Hildebrandt <thildebr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#531690}
parent 3fe960d2
...@@ -39,16 +39,12 @@ import java.util.concurrent.ExecutionException; ...@@ -39,16 +39,12 @@ import java.util.concurrent.ExecutionException;
@CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE}) @CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE})
public class DefaultSearchEnginePromoDialogTest { public class DefaultSearchEnginePromoDialogTest {
@Before @Before
public void setUp() throws Exception { public void setUp() throws ExecutionException, ProcessInitException {
ThreadUtils.runOnUiThreadBlocking(new Runnable() { ThreadUtils.runOnUiThreadBlocking(new Callable<Void>() {
@Override @Override
public void run() { public Void call() throws ProcessInitException {
try { ChromeBrowserInitializer.getInstance(InstrumentationRegistry.getTargetContext())
ChromeBrowserInitializer.getInstance(InstrumentationRegistry.getTargetContext()) .handleSynchronousStartup();
.handleSynchronousStartup();
} catch (ProcessInitException e) {
throw new AssertionError("Failed to initialize Chrome process.", e);
}
LocaleManager mockManager = new LocaleManager() { LocaleManager mockManager = new LocaleManager() {
@Override @Override
...@@ -57,6 +53,7 @@ public class DefaultSearchEnginePromoDialogTest { ...@@ -57,6 +53,7 @@ public class DefaultSearchEnginePromoDialogTest {
} }
}; };
LocaleManager.setInstanceForTest(mockManager); LocaleManager.setInstanceForTest(mockManager);
return null;
} }
}); });
} }
......
...@@ -25,6 +25,8 @@ import org.chromium.chrome.browser.search_engines.TemplateUrlService; ...@@ -25,6 +25,8 @@ import org.chromium.chrome.browser.search_engines.TemplateUrlService;
import org.chromium.chrome.test.util.ApplicationData; import org.chromium.chrome.test.util.ApplicationData;
import java.util.Locale; import java.util.Locale;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeoutException; import java.util.concurrent.TimeoutException;
/** /**
...@@ -36,7 +38,7 @@ public class LocaleManagerReferralTest { ...@@ -36,7 +38,7 @@ public class LocaleManagerReferralTest {
private String mYandexReferralId = ""; private String mYandexReferralId = "";
@Before @Before
public void setUp() { public void setUp() throws ExecutionException, ProcessInitException {
mDefaultLocale = Locale.getDefault(); mDefaultLocale = Locale.getDefault();
Locale.setDefault(new Locale("ru", "RU")); Locale.setDefault(new Locale("ru", "RU"));
...@@ -49,15 +51,12 @@ public class LocaleManagerReferralTest { ...@@ -49,15 +51,12 @@ public class LocaleManagerReferralTest {
} }
}); });
ThreadUtils.runOnUiThreadBlocking(new Runnable() { ThreadUtils.runOnUiThreadBlocking(new Callable<Void>() {
@Override @Override
public void run() { public Void call() throws ProcessInitException {
try { ChromeBrowserInitializer.getInstance(InstrumentationRegistry.getTargetContext())
ChromeBrowserInitializer.getInstance(InstrumentationRegistry.getTargetContext()) .handleSynchronousStartup();
.handleSynchronousStartup(); return null;
} catch (ProcessInitException e) {
throw new AssertionError("Failed to load browser.", e);
}
} }
}); });
} }
......
...@@ -24,6 +24,8 @@ import org.chromium.chrome.test.ChromeJUnit4ClassRunner; ...@@ -24,6 +24,8 @@ import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
import org.chromium.chrome.test.util.ActivityUtils; import org.chromium.chrome.test.util.ActivityUtils;
import org.chromium.policy.test.annotations.Policies; import org.chromium.policy.test.annotations.Policies;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeoutException; import java.util.concurrent.TimeoutException;
/** /**
...@@ -33,16 +35,13 @@ import java.util.concurrent.TimeoutException; ...@@ -33,16 +35,13 @@ import java.util.concurrent.TimeoutException;
@CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE}) @CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE})
public class LocaleManagerTest { public class LocaleManagerTest {
@Before @Before
public void setUp() { public void setUp() throws ExecutionException, ProcessInitException {
ThreadUtils.runOnUiThreadBlocking(new Runnable() { ThreadUtils.runOnUiThreadBlocking(new Callable<Void>() {
@Override @Override
public void run() { public Void call() throws ProcessInitException {
try { ChromeBrowserInitializer.getInstance(InstrumentationRegistry.getTargetContext())
ChromeBrowserInitializer.getInstance(InstrumentationRegistry.getTargetContext()) .handleSynchronousStartup();
.handleSynchronousStartup(); return null;
} catch (ProcessInitException e) {
throw new AssertionError("Failed to load browser.", e);
}
} }
}); });
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment