OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 android.content.Context; | 7 import android.content.Context; |
8 import android.os.Environment; | 8 import android.os.Environment; |
9 import android.test.suitebuilder.annotation.SmallTest; | 9 import android.test.suitebuilder.annotation.SmallTest; |
10 | 10 |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
251 @SmallTest | 251 @SmallTest |
252 public void testGetOfflineUrlForOnlineUrl() throws Exception { | 252 public void testGetOfflineUrlForOnlineUrl() throws Exception { |
253 loadUrl(mTestPage); | 253 loadUrl(mTestPage); |
254 savePage(SavePageResult.SUCCESS, mTestPage); | 254 savePage(SavePageResult.SUCCESS, mTestPage); |
255 OfflinePageItem offlinePage = mOfflinePageBridge.getPageByClientId(BOOKM ARK_ID); | 255 OfflinePageItem offlinePage = mOfflinePageBridge.getPageByClientId(BOOKM ARK_ID); |
256 assertEquals("We should get the same offline URL, when querying using on line URL", | 256 assertEquals("We should get the same offline URL, when querying using on line URL", |
257 offlinePage.getOfflineUrl(), | 257 offlinePage.getOfflineUrl(), |
258 mOfflinePageBridge.getOfflineUrlForOnlineUrl(offlinePage.getUrl( ))); | 258 mOfflinePageBridge.getOfflineUrlForOnlineUrl(offlinePage.getUrl( ))); |
259 } | 259 } |
260 | 260 |
261 @SmallTest | |
262 public void testBackgroundLoadSwitch() throws Exception { | |
Ted C
2016/03/14 22:16:41
To be safe, wouldn't you want to add something lik
| |
263 // We should be able to call the C++ is enabled function from the Java s ide. | |
264 assertFalse("If background loading is off, we should see the feature dis abled", | |
265 OfflinePageBridge.isBackgroundLoadingEnabled()); | |
266 } | |
267 | |
261 private void savePage(final int expectedResult, final String expectedUrl) | 268 private void savePage(final int expectedResult, final String expectedUrl) |
262 throws InterruptedException { | 269 throws InterruptedException { |
263 final Semaphore semaphore = new Semaphore(0); | 270 final Semaphore semaphore = new Semaphore(0); |
264 ThreadUtils.runOnUiThreadBlocking(new Runnable() { | 271 ThreadUtils.runOnUiThreadBlocking(new Runnable() { |
265 @Override | 272 @Override |
266 public void run() { | 273 public void run() { |
267 assertNotNull("Tab is null", getActivity().getActivityTab()); | 274 assertNotNull("Tab is null", getActivity().getActivityTab()); |
268 assertEquals("URL does not match requested.", mTestPage, | 275 assertEquals("URL does not match requested.", mTestPage, |
269 getActivity().getActivityTab().getUrl()); | 276 getActivity().getActivityTab().getUrl()); |
270 assertNotNull("WebContents is null", | 277 assertNotNull("WebContents is null", |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
322 | 329 |
323 private void forceConnectivityStateOnUiThread(final boolean state) { | 330 private void forceConnectivityStateOnUiThread(final boolean state) { |
324 ThreadUtils.runOnUiThreadBlocking(new Runnable() { | 331 ThreadUtils.runOnUiThreadBlocking(new Runnable() { |
325 @Override | 332 @Override |
326 public void run() { | 333 public void run() { |
327 NetworkChangeNotifier.forceConnectivityState(state); | 334 NetworkChangeNotifier.forceConnectivityState(state); |
328 } | 335 } |
329 }); | 336 }); |
330 } | 337 } |
331 } | 338 } |
OLD | NEW |