Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3367)

Unified Diff: base/android/javatests/src/org/chromium/base/AdvancedMockContextTest.java

Issue 2726003002: Auto convert base javatests in content shell apk to JUnit4 (Closed)
Patch Set: Rebase Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/BUILD.gn ('k') | base/android/javatests/src/org/chromium/base/ApiCompatibilityUtilsTest.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/android/javatests/src/org/chromium/base/AdvancedMockContextTest.java
diff --git a/base/android/javatests/src/org/chromium/base/AdvancedMockContextTest.java b/base/android/javatests/src/org/chromium/base/AdvancedMockContextTest.java
index f0da3bd0658a85be8e2969094c341dfde606833a..20c626d1945ee81fc9d86344e28d300f0a7f6dc3 100644
--- a/base/android/javatests/src/org/chromium/base/AdvancedMockContextTest.java
+++ b/base/android/javatests/src/org/chromium/base/AdvancedMockContextTest.java
@@ -1,4 +1,4 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
+// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -9,15 +9,21 @@ import android.content.ComponentCallbacks;
import android.content.ComponentCallbacks2;
import android.content.Context;
import android.content.res.Configuration;
+import android.support.test.InstrumentationRegistry;
import android.support.test.filters.SmallTest;
-import android.test.InstrumentationTestCase;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import org.chromium.base.test.BaseJUnit4ClassRunner;
import org.chromium.base.test.util.AdvancedMockContext;
/**
* Tests for {@link org.chromium.base.test.util.AdvancedMockContext}.
*/
-public class AdvancedMockContextTest extends InstrumentationTestCase {
+@RunWith(BaseJUnit4ClassRunner.class)
+public class AdvancedMockContextTest {
private static class Callback1 implements ComponentCallbacks {
protected Configuration mConfiguration;
protected boolean mOnLowMemoryCalled;
@@ -42,9 +48,10 @@ public class AdvancedMockContextTest extends InstrumentationTestCase {
}
}
+ @Test
@SmallTest
public void testComponentCallbacksForTargetContext() {
- Context targetContext = getInstrumentation().getTargetContext();
+ Context targetContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
Application targetApplication = (Application) targetContext.getApplicationContext();
AdvancedMockContext context = new AdvancedMockContext(targetContext);
Callback1 callback1 = new Callback1();
@@ -53,18 +60,18 @@ public class AdvancedMockContextTest extends InstrumentationTestCase {
context.registerComponentCallbacks(callback2);
targetApplication.onLowMemory();
- assertTrue("onLowMemory should have been called.", callback1.mOnLowMemoryCalled);
- assertTrue("onLowMemory should have been called.", callback2.mOnLowMemoryCalled);
+ Assert.assertTrue("onLowMemory should have been called.", callback1.mOnLowMemoryCalled);
+ Assert.assertTrue("onLowMemory should have been called.", callback2.mOnLowMemoryCalled);
Configuration configuration = new Configuration();
targetApplication.onConfigurationChanged(configuration);
- assertEquals("onConfigurationChanged should have been called.", configuration,
+ Assert.assertEquals("onConfigurationChanged should have been called.", configuration,
callback1.mConfiguration);
- assertEquals("onConfigurationChanged should have been called.", configuration,
+ Assert.assertEquals("onConfigurationChanged should have been called.", configuration,
callback2.mConfiguration);
targetApplication.onTrimMemory(ComponentCallbacks2.TRIM_MEMORY_MODERATE);
- assertEquals("onTrimMemory should have been called.", ComponentCallbacks2
- .TRIM_MEMORY_MODERATE, callback2.mLevel);
+ Assert.assertEquals("onTrimMemory should have been called.",
+ ComponentCallbacks2.TRIM_MEMORY_MODERATE, callback2.mLevel);
}
}
« no previous file with comments | « base/BUILD.gn ('k') | base/android/javatests/src/org/chromium/base/ApiCompatibilityUtilsTest.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698