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 @CommandLineFlags.Add("disable-features=offline-pages-background-loading") |
| 262 @SmallTest |
| 263 public void testBackgroundLoadSwitch() throws Exception { |
| 264 // We should be able to call the C++ is enabled function from the Java s
ide. |
| 265 assertFalse("If background loading is off, we should see the feature dis
abled", |
| 266 OfflinePageBridge.isBackgroundLoadingEnabled()); |
| 267 } |
| 268 |
261 private void savePage(final int expectedResult, final String expectedUrl) | 269 private void savePage(final int expectedResult, final String expectedUrl) |
262 throws InterruptedException { | 270 throws InterruptedException { |
263 final Semaphore semaphore = new Semaphore(0); | 271 final Semaphore semaphore = new Semaphore(0); |
264 ThreadUtils.runOnUiThreadBlocking(new Runnable() { | 272 ThreadUtils.runOnUiThreadBlocking(new Runnable() { |
265 @Override | 273 @Override |
266 public void run() { | 274 public void run() { |
267 assertNotNull("Tab is null", getActivity().getActivityTab()); | 275 assertNotNull("Tab is null", getActivity().getActivityTab()); |
268 assertEquals("URL does not match requested.", mTestPage, | 276 assertEquals("URL does not match requested.", mTestPage, |
269 getActivity().getActivityTab().getUrl()); | 277 getActivity().getActivityTab().getUrl()); |
270 assertNotNull("WebContents is null", | 278 assertNotNull("WebContents is null", |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 | 330 |
323 private void forceConnectivityStateOnUiThread(final boolean state) { | 331 private void forceConnectivityStateOnUiThread(final boolean state) { |
324 ThreadUtils.runOnUiThreadBlocking(new Runnable() { | 332 ThreadUtils.runOnUiThreadBlocking(new Runnable() { |
325 @Override | 333 @Override |
326 public void run() { | 334 public void run() { |
327 NetworkChangeNotifier.forceConnectivityState(state); | 335 NetworkChangeNotifier.forceConnectivityState(state); |
328 } | 336 } |
329 }); | 337 }); |
330 } | 338 } |
331 } | 339 } |
OLD | NEW |