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

Side by Side Diff: ios/chrome/browser/ui/fullscreen_egtest.mm

Issue 2751523004: Move EarlGrey helper to check toolbar visibility into ChromeEarlGreyUI. (Closed)
Patch Set: return void 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 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 #import <EarlGrey/EarlGrey.h> 5 #import <EarlGrey/EarlGrey.h>
6 #import <UIKit/UIKit.h> 6 #import <UIKit/UIKit.h>
7 #import <XCTest/XCTest.h> 7 #import <XCTest/XCTest.h>
8 8
9 #include "base/ios/ios_util.h" 9 #include "base/ios/ios_util.h"
10 #include "base/mac/bind_objc_block.h" 10 #include "base/mac/bind_objc_block.h"
11 #include "base/strings/stringprintf.h" 11 #include "base/strings/stringprintf.h"
12 #include "base/strings/sys_string_conversions.h" 12 #include "base/strings/sys_string_conversions.h"
13 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
14 #import "ios/chrome/browser/ui/toolbar/toolbar_controller.h" 14 #import "ios/chrome/browser/ui/toolbar/toolbar_controller.h"
15 #import "ios/chrome/test/app/chrome_test_util.h" 15 #import "ios/chrome/test/app/chrome_test_util.h"
16 #import "ios/chrome/test/app/settings_test_util.h" 16 #import "ios/chrome/test/app/settings_test_util.h"
17 #import "ios/chrome/test/app/web_view_interaction_test_util.h" 17 #import "ios/chrome/test/app/web_view_interaction_test_util.h"
18 #include "ios/chrome/test/earl_grey/chrome_assertions.h" 18 #include "ios/chrome/test/earl_grey/chrome_assertions.h"
19 #import "ios/chrome/test/earl_grey/chrome_earl_grey.h" 19 #import "ios/chrome/test/earl_grey/chrome_earl_grey.h"
20 #import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h"
20 #import "ios/chrome/test/earl_grey/chrome_matchers.h" 21 #import "ios/chrome/test/earl_grey/chrome_matchers.h"
21 #import "ios/chrome/test/earl_grey/chrome_test_case.h" 22 #import "ios/chrome/test/earl_grey/chrome_test_case.h"
22 #import "ios/chrome/test/earl_grey/chrome_util.h"
23 #import "ios/testing/wait_util.h" 23 #import "ios/testing/wait_util.h"
24 #import "ios/web/public/test/earl_grey/web_view_matchers.h" 24 #import "ios/web/public/test/earl_grey/web_view_matchers.h"
25 #import "ios/web/public/test/http_server.h" 25 #import "ios/web/public/test/http_server.h"
26 #import "ios/web/public/test/http_server_util.h" 26 #import "ios/web/public/test/http_server_util.h"
27 #import "ios/web/public/test/response_providers/error_page_response_provider.h" 27 #import "ios/web/public/test/response_providers/error_page_response_provider.h"
28 #import "ios/web/public/test/web_view_interaction_test_util.h" 28 #import "ios/web/public/test/web_view_interaction_test_util.h"
29 #include "url/gurl.h" 29 #include "url/gurl.h"
30 30
31 #if !defined(__has_feature) || !__has_feature(objc_arc) 31 #if !defined(__has_feature) || !__has_feature(objc_arc)
32 #error "This file requires ARC support." 32 #error "This file requires ARC support."
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 @implementation FullscreenTestCase 97 @implementation FullscreenTestCase
98 98
99 // Verifies that the content offset of the web view is set up at the correct 99 // Verifies that the content offset of the web view is set up at the correct
100 // initial value when initially displaying a PDF. 100 // initial value when initially displaying a PDF.
101 - (void)testLongPDFInitialState { 101 - (void)testLongPDFInitialState {
102 web::test::SetUpFileBasedHttpServer(); 102 web::test::SetUpFileBasedHttpServer();
103 GURL URL = web::test::HttpServer::MakeUrl( 103 GURL URL = web::test::HttpServer::MakeUrl(
104 "http://ios/testing/data/http_server_files/two_pages.pdf"); 104 "http://ios/testing/data/http_server_files/two_pages.pdf");
105 [ChromeEarlGrey loadURL:URL]; 105 [ChromeEarlGrey loadURL:URL];
106 106
107 chrome_test_util::AssertToolbarVisible(); 107 [ChromeEarlGreyUI waitForToolbarVisible:YES];
108 // Initial y scroll position is -56 on iPhone and -95 on iPad, to make room 108 // Initial y scroll position is -56 on iPhone and -95 on iPad, to make room
109 // for the toolbar. 109 // for the toolbar.
110 // TODO(crbug.com/618887) Replace use of specific values when API which 110 // TODO(crbug.com/618887) Replace use of specific values when API which
111 // generates these values is exposed. 111 // generates these values is exposed.
112 CGFloat yOffset = IsIPadIdiom() ? -95.0 : -56.0; 112 CGFloat yOffset = IsIPadIdiom() ? -95.0 : -56.0;
113 [[EarlGrey 113 [[EarlGrey
114 selectElementWithMatcher:web::WebViewScrollView( 114 selectElementWithMatcher:web::WebViewScrollView(
115 chrome_test_util::GetCurrentWebState())] 115 chrome_test_util::GetCurrentWebState())]
116 assertWithMatcher:ContentOffset(CGPointMake(0, yOffset))]; 116 assertWithMatcher:ContentOffset(CGPointMake(0, yOffset))];
117 } 117 }
118 118
119 // Verifies that the toolbar properly appears/disappears when scrolling up/down 119 // Verifies that the toolbar properly appears/disappears when scrolling up/down
120 // on a PDF that is short in length and wide in width. 120 // on a PDF that is short in length and wide in width.
121 - (void)testSmallWidePDFScroll { 121 - (void)testSmallWidePDFScroll {
122 web::test::SetUpFileBasedHttpServer(); 122 web::test::SetUpFileBasedHttpServer();
123 GURL URL = web::test::HttpServer::MakeUrl( 123 GURL URL = web::test::HttpServer::MakeUrl(
124 "http://ios/testing/data/http_server_files/single_page_wide.pdf"); 124 "http://ios/testing/data/http_server_files/single_page_wide.pdf");
125 [ChromeEarlGrey loadURL:URL]; 125 [ChromeEarlGrey loadURL:URL];
126 126
127 // Test that the toolbar is still visible after a user swipes down. 127 // Test that the toolbar is still visible after a user swipes down.
128 [[EarlGrey 128 [[EarlGrey
129 selectElementWithMatcher:WebViewScrollView( 129 selectElementWithMatcher:WebViewScrollView(
130 chrome_test_util::GetCurrentWebState())] 130 chrome_test_util::GetCurrentWebState())]
131 performAction:grey_swipeFastInDirection(kGREYDirectionDown)]; 131 performAction:grey_swipeFastInDirection(kGREYDirectionDown)];
132 chrome_test_util::AssertToolbarVisible(); 132 [ChromeEarlGreyUI waitForToolbarVisible:YES];
133 133
134 // Test that the toolbar is no longer visible after a user swipes up. 134 // Test that the toolbar is no longer visible after a user swipes up.
135 HideToolbarUsingUI(); 135 HideToolbarUsingUI();
136 chrome_test_util::AssertToolbarNotVisible(); 136 [ChromeEarlGreyUI waitForToolbarVisible:NO];
137 } 137 }
138 138
139 // Verifies that the toolbar properly appears/disappears when scrolling up/down 139 // Verifies that the toolbar properly appears/disappears when scrolling up/down
140 // on a PDF that is long in length and wide in width. 140 // on a PDF that is long in length and wide in width.
141 - (void)testLongPDFScroll { 141 - (void)testLongPDFScroll {
142 web::test::SetUpFileBasedHttpServer(); 142 web::test::SetUpFileBasedHttpServer();
143 GURL URL = web::test::HttpServer::MakeUrl( 143 GURL URL = web::test::HttpServer::MakeUrl(
144 "http://ios/testing/data/http_server_files/two_pages.pdf"); 144 "http://ios/testing/data/http_server_files/two_pages.pdf");
145 [ChromeEarlGrey loadURL:URL]; 145 [ChromeEarlGrey loadURL:URL];
146 146
147 // Test that the toolbar is hidden after a user swipes up. 147 // Test that the toolbar is hidden after a user swipes up.
148 HideToolbarUsingUI(); 148 HideToolbarUsingUI();
149 chrome_test_util::AssertToolbarNotVisible(); 149 [ChromeEarlGreyUI waitForToolbarVisible:NO];
150 150
151 // Test that the toolbar is visible after a user swipes down. 151 // Test that the toolbar is visible after a user swipes down.
152 [[EarlGrey 152 [[EarlGrey
153 selectElementWithMatcher:WebViewScrollView( 153 selectElementWithMatcher:WebViewScrollView(
154 chrome_test_util::GetCurrentWebState())] 154 chrome_test_util::GetCurrentWebState())]
155 performAction:grey_swipeFastInDirection(kGREYDirectionDown)]; 155 performAction:grey_swipeFastInDirection(kGREYDirectionDown)];
156 chrome_test_util::AssertToolbarVisible(); 156 [ChromeEarlGreyUI waitForToolbarVisible:YES];
157 157
158 // Test that the toolbar is hidden after a user swipes up. 158 // Test that the toolbar is hidden after a user swipes up.
159 HideToolbarUsingUI(); 159 HideToolbarUsingUI();
160 chrome_test_util::AssertToolbarNotVisible(); 160 [ChromeEarlGreyUI waitForToolbarVisible:NO];
161 } 161 }
162 162
163 // Tests that link clicks from a chrome:// to chrome:// link result in the 163 // Tests that link clicks from a chrome:// to chrome:// link result in the
164 // header being shown even if was not previously shown. 164 // header being shown even if was not previously shown.
165 - (void)testChromeToChromeURLKeepsHeaderOnScreen { 165 - (void)testChromeToChromeURLKeepsHeaderOnScreen {
166 const GURL kChromeAboutURL("chrome://chrome-urls"); 166 const GURL kChromeAboutURL("chrome://chrome-urls");
167 [ChromeEarlGrey loadURL:kChromeAboutURL]; 167 [ChromeEarlGrey loadURL:kChromeAboutURL];
168 168
169 AssertStringIsPresentOnPage("chrome://version"); 169 AssertStringIsPresentOnPage("chrome://version");
170 170
(...skipping 24 matching lines...) Expand all
195 @"JavaScript to hide the toolbar did not complete"); 195 @"JavaScript to hide the toolbar did not complete");
196 196
197 // Scroll up to be sure the toolbar can be dismissed by scrolling down. 197 // Scroll up to be sure the toolbar can be dismissed by scrolling down.
198 [[EarlGrey 198 [[EarlGrey
199 selectElementWithMatcher:WebViewScrollView( 199 selectElementWithMatcher:WebViewScrollView(
200 chrome_test_util::GetCurrentWebState())] 200 chrome_test_util::GetCurrentWebState())]
201 performAction:grey_swipeFastInDirection(kGREYDirectionDown)]; 201 performAction:grey_swipeFastInDirection(kGREYDirectionDown)];
202 202
203 // Scroll to hide the UI. 203 // Scroll to hide the UI.
204 HideToolbarUsingUI(); 204 HideToolbarUsingUI();
205 chrome_test_util::AssertToolbarNotVisible(); 205 [ChromeEarlGreyUI waitForToolbarVisible:NO];
206 206
207 // Test that the toolbar is visible when moving from one chrome:// link to 207 // Test that the toolbar is visible when moving from one chrome:// link to
208 // another chrome:// link. 208 // another chrome:// link.
209 chrome_test_util::TapWebViewElementWithId("version"); 209 chrome_test_util::TapWebViewElementWithId("version");
210 chrome_test_util::AssertToolbarVisible(); 210 [ChromeEarlGreyUI waitForToolbarVisible:YES];
211 } 211 }
212 212
213 // Tests hiding and showing of the header with a user scroll on a long page. 213 // Tests hiding and showing of the header with a user scroll on a long page.
214 - (void)testHideHeaderUserScrollLongPage { 214 - (void)testHideHeaderUserScrollLongPage {
215 std::map<GURL, std::string> responses; 215 std::map<GURL, std::string> responses;
216 const GURL URL = web::test::HttpServer::MakeUrl("http://tallpage"); 216 const GURL URL = web::test::HttpServer::MakeUrl("http://tallpage");
217 217
218 // A page long enough to ensure that the toolbar goes away on scrolling. 218 // A page long enough to ensure that the toolbar goes away on scrolling.
219 responses[URL] = "<p style='height:200em'>a</p><p>b</p>"; 219 responses[URL] = "<p style='height:200em'>a</p><p>b</p>";
220 web::test::SetUpSimpleHttpServer(responses); 220 web::test::SetUpSimpleHttpServer(responses);
221 221
222 [ChromeEarlGrey loadURL:URL]; 222 [ChromeEarlGrey loadURL:URL];
223 chrome_test_util::AssertToolbarVisible(); 223 [ChromeEarlGreyUI waitForToolbarVisible:YES];
224 // Simulate a user scroll down. 224 // Simulate a user scroll down.
225 HideToolbarUsingUI(); 225 HideToolbarUsingUI();
226 chrome_test_util::AssertToolbarNotVisible(); 226 [ChromeEarlGreyUI waitForToolbarVisible:NO];
227 // Simulate a user scroll up. 227 // Simulate a user scroll up.
228 [[EarlGrey 228 [[EarlGrey
229 selectElementWithMatcher:WebViewScrollView( 229 selectElementWithMatcher:WebViewScrollView(
230 chrome_test_util::GetCurrentWebState())] 230 chrome_test_util::GetCurrentWebState())]
231 performAction:grey_swipeFastInDirection(kGREYDirectionDown)]; 231 performAction:grey_swipeFastInDirection(kGREYDirectionDown)];
232 chrome_test_util::AssertToolbarVisible(); 232 [ChromeEarlGreyUI waitForToolbarVisible:YES];
233 } 233 }
234 234
235 // Tests that reloading of a page shows the header even if it was not shown 235 // Tests that reloading of a page shows the header even if it was not shown
236 // previously. 236 // previously.
237 - (void)testShowHeaderOnReload { 237 - (void)testShowHeaderOnReload {
238 std::map<GURL, std::string> responses; 238 std::map<GURL, std::string> responses;
239 const GURL URL = web::test::HttpServer::MakeUrl("http://origin"); 239 const GURL URL = web::test::HttpServer::MakeUrl("http://origin");
240 // This is a tall page -- necessary to make sure scrolling can hide away the 240 // This is a tall page -- necessary to make sure scrolling can hide away the
241 // toolbar safely-- and with a link to reload itself. 241 // toolbar safely-- and with a link to reload itself.
242 responses[URL] = 242 responses[URL] =
243 "<p style='height:200em'>Tall page</p>" 243 "<p style='height:200em'>Tall page</p>"
244 "<a onclick='window.location.reload();' id='link'>link</a>"; 244 "<a onclick='window.location.reload();' id='link'>link</a>";
245 web::test::SetUpSimpleHttpServer(responses); 245 web::test::SetUpSimpleHttpServer(responses);
246 246
247 [ChromeEarlGrey loadURL:URL]; 247 [ChromeEarlGrey loadURL:URL];
248 AssertStringIsPresentOnPage("Tall page"); 248 AssertStringIsPresentOnPage("Tall page");
249 249
250 // Hide the toolbar. 250 // Hide the toolbar.
251 HideToolbarUsingUI(); 251 HideToolbarUsingUI();
252 chrome_test_util::AssertToolbarNotVisible(); 252 [ChromeEarlGreyUI waitForToolbarVisible:NO];
253 253
254 chrome_test_util::TapWebViewElementWithId("link"); 254 chrome_test_util::TapWebViewElementWithId("link");
255 255
256 // Main test is here: Make sure the header is still visible! 256 // Main test is here: Make sure the header is still visible!
257 chrome_test_util::AssertToolbarVisible(); 257 [ChromeEarlGreyUI waitForToolbarVisible:YES];
258 } 258 }
259 259
260 // Test to make sure the header is shown when a Tab opened by the current Tab is 260 // Test to make sure the header is shown when a Tab opened by the current Tab is
261 // closed even if the toolbar was not present previously. 261 // closed even if the toolbar was not present previously.
262 - (void)testShowHeaderWhenChildTabCloses { 262 - (void)testShowHeaderWhenChildTabCloses {
263 std::map<GURL, std::string> responses; 263 std::map<GURL, std::string> responses;
264 const GURL URL = web::test::HttpServer::MakeUrl("http://origin"); 264 const GURL URL = web::test::HttpServer::MakeUrl("http://origin");
265 const GURL destinationURL = 265 const GURL destinationURL =
266 web::test::HttpServer::MakeUrl("http://destination"); 266 web::test::HttpServer::MakeUrl("http://destination");
267 // JavaScript to open a window using window.open. 267 // JavaScript to open a window using window.open.
(...skipping 15 matching lines...) Expand all
283 283
284 web::test::SetUpSimpleHttpServer(responses); 284 web::test::SetUpSimpleHttpServer(responses);
285 chrome_test_util::SetContentSettingsBlockPopups(CONTENT_SETTING_ALLOW); 285 chrome_test_util::SetContentSettingsBlockPopups(CONTENT_SETTING_ALLOW);
286 286
287 [ChromeEarlGrey loadURL:URL]; 287 [ChromeEarlGrey loadURL:URL];
288 AssertStringIsPresentOnPage("link1"); 288 AssertStringIsPresentOnPage("link1");
289 chrome_test_util::AssertMainTabCount(1); 289 chrome_test_util::AssertMainTabCount(1);
290 290
291 // Hide the toolbar. 291 // Hide the toolbar.
292 HideToolbarUsingUI(); 292 HideToolbarUsingUI();
293 chrome_test_util::AssertToolbarNotVisible(); 293 [ChromeEarlGreyUI waitForToolbarVisible:NO];
294 294
295 // Open new window. 295 // Open new window.
296 chrome_test_util::TapWebViewElementWithId("link1"); 296 chrome_test_util::TapWebViewElementWithId("link1");
297 297
298 // Check that a new Tab was created. 298 // Check that a new Tab was created.
299 AssertStringIsPresentOnPage("link2"); 299 AssertStringIsPresentOnPage("link2");
300 chrome_test_util::AssertMainTabCount(2); 300 chrome_test_util::AssertMainTabCount(2);
301 301
302 AssertURLIs(destinationURL); 302 AssertURLIs(destinationURL);
303 303
304 // Hide the toolbar. 304 // Hide the toolbar.
305 HideToolbarUsingUI(); 305 HideToolbarUsingUI();
306 chrome_test_util::AssertToolbarNotVisible(); 306 [ChromeEarlGreyUI waitForToolbarVisible:NO];
307 307
308 // Close the tab. 308 // Close the tab.
309 chrome_test_util::TapWebViewElementWithId("link2"); 309 chrome_test_util::TapWebViewElementWithId("link2");
310 AssertStringIsPresentOnPage("link1"); 310 AssertStringIsPresentOnPage("link1");
311 311
312 // Make sure the toolbar is on the screen. 312 // Make sure the toolbar is on the screen.
313 chrome_test_util::AssertMainTabCount(1); 313 chrome_test_util::AssertMainTabCount(1);
314 chrome_test_util::AssertToolbarVisible(); 314 [ChromeEarlGreyUI waitForToolbarVisible:YES];
315 } 315 }
316 316
317 // Tests that the header is shown when a regular page (non-native page) is 317 // Tests that the header is shown when a regular page (non-native page) is
318 // loaded from a page where the header was not see before. 318 // loaded from a page where the header was not see before.
319 // Also tests that auto-hide works correctly on new page loads. 319 // Also tests that auto-hide works correctly on new page loads.
320 - (void)testShowHeaderOnRegularPageLoad { 320 - (void)testShowHeaderOnRegularPageLoad {
321 std::map<GURL, std::string> responses; 321 std::map<GURL, std::string> responses;
322 const GURL originURL = web::test::HttpServer::MakeUrl("http://origin"); 322 const GURL originURL = web::test::HttpServer::MakeUrl("http://origin");
323 const GURL destinationURL = 323 const GURL destinationURL =
324 web::test::HttpServer::MakeUrl("http://destination"); 324 web::test::HttpServer::MakeUrl("http://destination");
325 325
326 const std::string manyLines = 326 const std::string manyLines =
327 "<p style='height:100em'>a</p><p>End of lines</p>"; 327 "<p style='height:100em'>a</p><p>End of lines</p>";
328 328
329 // A long page representing many lines and a link to the destination URL page. 329 // A long page representing many lines and a link to the destination URL page.
330 responses[originURL] = manyLines + "<a href='" + destinationURL.spec() + 330 responses[originURL] = manyLines + "<a href='" + destinationURL.spec() +
331 "' id='link1'>link1</a>"; 331 "' id='link1'>link1</a>";
332 // A long page representing many lines and a link to go back. 332 // A long page representing many lines and a link to go back.
333 responses[destinationURL] = manyLines + 333 responses[destinationURL] = manyLines +
334 "<a href='javascript:void(0)' " 334 "<a href='javascript:void(0)' "
335 "onclick='window.history.back()' " 335 "onclick='window.history.back()' "
336 "id='link2'>link2</a>"; 336 "id='link2'>link2</a>";
337 web::test::SetUpSimpleHttpServer(responses); 337 web::test::SetUpSimpleHttpServer(responses);
338 338
339 [ChromeEarlGrey loadURL:originURL]; 339 [ChromeEarlGrey loadURL:originURL];
340 340
341 AssertStringIsPresentOnPage("link1"); 341 AssertStringIsPresentOnPage("link1");
342 // Dismiss the toolbar. 342 // Dismiss the toolbar.
343 HideToolbarUsingUI(); 343 HideToolbarUsingUI();
344 chrome_test_util::AssertToolbarNotVisible(); 344 [ChromeEarlGreyUI waitForToolbarVisible:NO];
345 345
346 // Navigate to the other page. 346 // Navigate to the other page.
347 chrome_test_util::TapWebViewElementWithId("link1"); 347 chrome_test_util::TapWebViewElementWithId("link1");
348 AssertStringIsPresentOnPage("link2"); 348 AssertStringIsPresentOnPage("link2");
349 349
350 // Make sure toolbar is shown since a new load has started. 350 // Make sure toolbar is shown since a new load has started.
351 chrome_test_util::AssertToolbarVisible(); 351 [ChromeEarlGreyUI waitForToolbarVisible:YES];
352 352
353 // Dismiss the toolbar. 353 // Dismiss the toolbar.
354 HideToolbarUsingUI(); 354 HideToolbarUsingUI();
355 chrome_test_util::AssertToolbarNotVisible(); 355 [ChromeEarlGreyUI waitForToolbarVisible:NO];
356 356
357 // Go back. 357 // Go back.
358 chrome_test_util::TapWebViewElementWithId("link2"); 358 chrome_test_util::TapWebViewElementWithId("link2");
359 359
360 // Make sure the toolbar has loaded now that a new page has loaded. 360 // Make sure the toolbar has loaded now that a new page has loaded.
361 chrome_test_util::AssertToolbarVisible(); 361 [ChromeEarlGreyUI waitForToolbarVisible:YES];
362 } 362 }
363 363
364 // Tests that the header is shown when a native page is loaded from a page where 364 // Tests that the header is shown when a native page is loaded from a page where
365 // the header was not seen before. 365 // the header was not seen before.
366 - (void)testShowHeaderOnNativePageLoad { 366 - (void)testShowHeaderOnNativePageLoad {
367 std::map<GURL, std::string> responses; 367 std::map<GURL, std::string> responses;
368 const GURL URL = web::test::HttpServer::MakeUrl("http://origin"); 368 const GURL URL = web::test::HttpServer::MakeUrl("http://origin");
369 369
370 // A long page representing many lines and a link to go back. 370 // A long page representing many lines and a link to go back.
371 std::string manyLines = 371 std::string manyLines =
372 "<p style='height:100em'>a</p>" 372 "<p style='height:100em'>a</p>"
373 "<a onclick='window.history.back()' id='link'>link</a>"; 373 "<a onclick='window.history.back()' id='link'>link</a>";
374 responses[URL] = manyLines; 374 responses[URL] = manyLines;
375 web::test::SetUpSimpleHttpServer(responses); 375 web::test::SetUpSimpleHttpServer(responses);
376 376
377 [ChromeEarlGrey loadURL:URL]; 377 [ChromeEarlGrey loadURL:URL];
378 AssertStringIsPresentOnPage("link"); 378 AssertStringIsPresentOnPage("link");
379 379
380 // Dismiss the toolbar. 380 // Dismiss the toolbar.
381 HideToolbarUsingUI(); 381 HideToolbarUsingUI();
382 chrome_test_util::AssertToolbarNotVisible(); 382 [ChromeEarlGreyUI waitForToolbarVisible:NO];
383 383
384 // Go back to NTP, which is a native view. 384 // Go back to NTP, which is a native view.
385 chrome_test_util::TapWebViewElementWithId("link"); 385 chrome_test_util::TapWebViewElementWithId("link");
386 386
387 // Make sure the toolbar is visible now that a new page has loaded. 387 // Make sure the toolbar is visible now that a new page has loaded.
388 chrome_test_util::AssertToolbarVisible(); 388 [ChromeEarlGreyUI waitForToolbarVisible:YES];
389 } 389 }
390 390
391 // Tests that the header is shown when loading an error page in a native view 391 // Tests that the header is shown when loading an error page in a native view
392 // even if fullscreen was enabled previously. 392 // even if fullscreen was enabled previously.
393 - (void)testShowHeaderOnErrorPage { 393 - (void)testShowHeaderOnErrorPage {
394 std::map<GURL, std::string> responses; 394 std::map<GURL, std::string> responses;
395 const GURL URL = web::test::HttpServer::MakeUrl("http://origin"); 395 const GURL URL = web::test::HttpServer::MakeUrl("http://origin");
396 // A long page with some simple text -- a long page is necessary so that 396 // A long page with some simple text -- a long page is necessary so that
397 // enough content is present to ensure that the toolbar can be hidden safely. 397 // enough content is present to ensure that the toolbar can be hidden safely.
398 responses[URL] = base::StringPrintf( 398 responses[URL] = base::StringPrintf(
399 "<p style='height:100em'>a</p>" 399 "<p style='height:100em'>a</p>"
400 "<a href=\"%s\" id=\"link\">bad link</a>", 400 "<a href=\"%s\" id=\"link\">bad link</a>",
401 ErrorPageResponseProvider::GetDnsFailureUrl().spec().c_str()); 401 ErrorPageResponseProvider::GetDnsFailureUrl().spec().c_str());
402 std::unique_ptr<web::DataResponseProvider> provider( 402 std::unique_ptr<web::DataResponseProvider> provider(
403 new ErrorPageResponseProvider(responses)); 403 new ErrorPageResponseProvider(responses));
404 web::test::SetUpHttpServer(std::move(provider)); 404 web::test::SetUpHttpServer(std::move(provider));
405 405
406 [ChromeEarlGrey loadURL:URL]; 406 [ChromeEarlGrey loadURL:URL];
407 HideToolbarUsingUI(); 407 HideToolbarUsingUI();
408 chrome_test_util::AssertToolbarNotVisible(); 408 [ChromeEarlGreyUI waitForToolbarVisible:NO];
409 409
410 chrome_test_util::TapWebViewElementWithId("link"); 410 chrome_test_util::TapWebViewElementWithId("link");
411 AssertURLIs(ErrorPageResponseProvider::GetDnsFailureUrl()); 411 AssertURLIs(ErrorPageResponseProvider::GetDnsFailureUrl());
412 chrome_test_util::AssertToolbarVisible(); 412 [ChromeEarlGreyUI waitForToolbarVisible:YES];
413 } 413 }
414 414
415 @end 415 @end
OLDNEW
« no previous file with comments | « ios/chrome/browser/context_menu/context_menu_egtest.mm ('k') | ios/chrome/browser/web/progress_indicator_egtest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698