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

Side by Side Diff: chrome/android/junit/src/org/chromium/chrome/browser/offlinepages/BackgroundSchedulerTest.java

Issue 2698143005: [Offline pages] Ensuring obtaining GcmNetworkManager in BackgroundScheduler does not throw (Closed)
Patch Set: Fixing date in copyright header Created 3 years, 10 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.chrome.browser.offlinepages; 5 package org.chromium.chrome.browser.offlinepages;
6 6
7 import static org.junit.Assert.assertEquals; 7 import static org.junit.Assert.assertEquals;
8 import static org.junit.Assert.assertNotNull; 8 import static org.junit.Assert.assertNotNull;
9 import static org.junit.Assert.assertNull; 9 import static org.junit.Assert.assertNull;
10 import static org.junit.Assert.assertTrue; 10 import static org.junit.Assert.assertTrue;
(...skipping 10 matching lines...) Expand all
21 import org.robolectric.annotation.Config; 21 import org.robolectric.annotation.Config;
22 import org.robolectric.internal.ShadowExtractor; 22 import org.robolectric.internal.ShadowExtractor;
23 23
24 import org.chromium.base.BaseChromiumApplication; 24 import org.chromium.base.BaseChromiumApplication;
25 import org.chromium.base.test.util.Feature; 25 import org.chromium.base.test.util.Feature;
26 26
27 /** 27 /**
28 * Unit tests for BackgroundScheduler. 28 * Unit tests for BackgroundScheduler.
29 */ 29 */
30 @RunWith(OfflinePageTestRunner.class) 30 @RunWith(OfflinePageTestRunner.class)
31 @Config(manifest = Config.NONE, 31 @Config(manifest = Config.NONE, application = BaseChromiumApplication.class,
32 application = BaseChromiumApplication.class, 32 shadows = {ShadowGcmNetworkManager.class, ShadowGoogleApiAvailability.cl ass})
33 shadows = {ShadowGcmNetworkManager.class})
34 public class BackgroundSchedulerTest { 33 public class BackgroundSchedulerTest {
35 private Context mContext; 34 private Context mContext;
36 private TriggerConditions mConditions1 = new TriggerConditions( 35 private TriggerConditions mConditions1 = new TriggerConditions(
37 true /* power */, 10 /* battery percentage */, false /* unmetered */ ); 36 true /* power */, 10 /* battery percentage */, false /* unmetered */ );
38 private ShadowGcmNetworkManager mGcmNetworkManager; 37 private ShadowGcmNetworkManager mGcmNetworkManager;
39 38
40 @Before 39 @Before
41 public void setUp() throws Exception { 40 public void setUp() throws Exception {
42 mContext = RuntimeEnvironment.application; 41 mContext = RuntimeEnvironment.application;
43 mGcmNetworkManager = (ShadowGcmNetworkManager) ShadowExtractor.extract( 42 mGcmNetworkManager = (ShadowGcmNetworkManager) ShadowExtractor.extract(
(...skipping 23 matching lines...) Expand all
67 public void testUnschedule() { 66 public void testUnschedule() {
68 assertNull(mGcmNetworkManager.getScheduledTask()); 67 assertNull(mGcmNetworkManager.getScheduledTask());
69 BackgroundScheduler.schedule(mContext, mConditions1); 68 BackgroundScheduler.schedule(mContext, mConditions1);
70 assertNotNull(mGcmNetworkManager.getScheduledTask()); 69 assertNotNull(mGcmNetworkManager.getScheduledTask());
71 70
72 assertNull(mGcmNetworkManager.getCanceledTask()); 71 assertNull(mGcmNetworkManager.getCanceledTask());
73 BackgroundScheduler.unschedule(mContext); 72 BackgroundScheduler.unschedule(mContext);
74 assertNotNull(mGcmNetworkManager.getCanceledTask()); 73 assertNotNull(mGcmNetworkManager.getCanceledTask());
75 } 74 }
76 } 75 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698