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

Side by Side Diff: chrome/android/javatests/src/org/chromium/chrome/browser/offlinepages/OfflinePageRequestTest.java

Issue 2431753003: Merge EmbeddedTestServer#createAndStartDefaultServer() and createAndStartFileServer() (Closed)
Patch Set: Merge branch 'master' into webapk_embedded_test_server Created 4 years, 1 month 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 android.os.Environment;
8 import android.test.suitebuilder.annotation.SmallTest; 7 import android.test.suitebuilder.annotation.SmallTest;
9 8
10 import org.chromium.base.ThreadUtils; 9 import org.chromium.base.ThreadUtils;
11 import org.chromium.base.test.util.CommandLineFlags; 10 import org.chromium.base.test.util.CommandLineFlags;
12 import org.chromium.base.test.util.RetryOnFailure; 11 import org.chromium.base.test.util.RetryOnFailure;
13 import org.chromium.chrome.browser.ChromeActivity; 12 import org.chromium.chrome.browser.ChromeActivity;
14 import org.chromium.chrome.browser.offlinepages.OfflinePageBridge.OfflinePageMod elObserver; 13 import org.chromium.chrome.browser.offlinepages.OfflinePageBridge.OfflinePageMod elObserver;
15 import org.chromium.chrome.browser.offlinepages.OfflinePageBridge.SavePageCallba ck; 14 import org.chromium.chrome.browser.offlinepages.OfflinePageBridge.SavePageCallba ck;
16 import org.chromium.chrome.browser.profiles.Profile; 15 import org.chromium.chrome.browser.profiles.Profile;
17 import org.chromium.chrome.browser.tab.Tab; 16 import org.chromium.chrome.browser.tab.Tab;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 } 73 }
75 74
76 @Override 75 @Override
77 public void startMainActivity() throws InterruptedException { 76 public void startMainActivity() throws InterruptedException {
78 startMainActivityOnBlankPage(); 77 startMainActivityOnBlankPage();
79 } 78 }
80 79
81 @SmallTest 80 @SmallTest
82 @RetryOnFailure 81 @RetryOnFailure
83 public void testLoadOfflinePageOnDisconnectedNetwork() throws Exception { 82 public void testLoadOfflinePageOnDisconnectedNetwork() throws Exception {
84 EmbeddedTestServer testServer = EmbeddedTestServer.createAndStartFileSer ver( 83 EmbeddedTestServer testServer = EmbeddedTestServer.createAndStartServer(
85 getInstrumentation().getContext(), Environment.getExternalStorag eDirectory()); 84 getInstrumentation().getContext());
86 String testUrl = testServer.getURL(TEST_PAGE); 85 String testUrl = testServer.getURL(TEST_PAGE);
87 String aboutUrl = testServer.getURL(ABOUT_PAGE); 86 String aboutUrl = testServer.getURL(ABOUT_PAGE);
88 87
89 Tab tab = getActivity().getActivityTab(); 88 Tab tab = getActivity().getActivityTab();
90 89
91 // Load and save an offline page. 90 // Load and save an offline page.
92 savePage(testUrl); 91 savePage(testUrl);
93 assertFalse(isErrorPage(tab)); 92 assertFalse(isErrorPage(tab));
94 assertFalse(isOfflinePage(tab)); 93 assertFalse(isOfflinePage(tab));
95 94
(...skipping 13 matching lines...) Expand all
109 108
110 // Load the page that has an offline copy. The offline page should be sh own. 109 // Load the page that has an offline copy. The offline page should be sh own.
111 loadUrl(testUrl); 110 loadUrl(testUrl);
112 assertFalse(isErrorPage(tab)); 111 assertFalse(isErrorPage(tab));
113 assertTrue(isOfflinePage(tab)); 112 assertTrue(isOfflinePage(tab));
114 } 113 }
115 114
116 @SmallTest 115 @SmallTest
117 @RetryOnFailure 116 @RetryOnFailure
118 public void testLoadOfflinePageWithFragmentOnDisconnectedNetwork() throws Ex ception { 117 public void testLoadOfflinePageWithFragmentOnDisconnectedNetwork() throws Ex ception {
119 EmbeddedTestServer testServer = EmbeddedTestServer.createAndStartFileSer ver( 118 EmbeddedTestServer testServer =
120 getInstrumentation().getContext(), Environment.getExternalStorag eDirectory()); 119 EmbeddedTestServer.createAndStartServer(getInstrumentation().get Context());
121 String testUrl = testServer.getURL(TEST_PAGE); 120 String testUrl = testServer.getURL(TEST_PAGE);
122 String testUrlWithFragment = testUrl + "#ref"; 121 String testUrlWithFragment = testUrl + "#ref";
123 122
124 Tab tab = getActivity().getActivityTab(); 123 Tab tab = getActivity().getActivityTab();
125 124
126 // Load and save an offline page for the url with a fragment. 125 // Load and save an offline page for the url with a fragment.
127 savePage(testUrlWithFragment); 126 savePage(testUrlWithFragment);
128 assertFalse(isErrorPage(tab)); 127 assertFalse(isErrorPage(tab));
129 assertFalse(isOfflinePage(tab)); 128 assertFalse(isOfflinePage(tab));
130 129
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 final boolean[] isShowingError = new boolean[1]; 179 final boolean[] isShowingError = new boolean[1];
181 ThreadUtils.runOnUiThreadBlocking(new Runnable() { 180 ThreadUtils.runOnUiThreadBlocking(new Runnable() {
182 @Override 181 @Override
183 public void run() { 182 public void run() {
184 isShowingError[0] = tab.isShowingErrorPage(); 183 isShowingError[0] = tab.isShowingErrorPage();
185 } 184 }
186 }); 185 });
187 return isShowingError[0]; 186 return isShowingError[0];
188 } 187 }
189 } 188 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698