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

Side by Side Diff: ios/chrome/browser/ui/history/history_ui_egtest.mm

Issue 2683453002: Extended HistoryUITestCase to test titles. (Closed)
Patch Set: Removed autorelease 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/strings/stringprintf.h"
9 #include "base/strings/sys_string_conversions.h" 10 #include "base/strings/sys_string_conversions.h"
10 #include "components/browsing_data/core/pref_names.h" 11 #include "components/browsing_data/core/pref_names.h"
11 #include "components/prefs/pref_service.h" 12 #include "components/prefs/pref_service.h"
12 #include "components/strings/grit/components_strings.h" 13 #include "components/strings/grit/components_strings.h"
13 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" 14 #include "ios/chrome/browser/browser_state/chrome_browser_state.h"
14 #include "ios/chrome/browser/chrome_url_constants.h" 15 #include "ios/chrome/browser/chrome_url_constants.h"
15 #import "ios/chrome/browser/ui/history/history_entry_item.h" 16 #import "ios/chrome/browser/ui/history/history_entry_item.h"
16 #import "ios/chrome/browser/ui/settings/clear_browsing_data_collection_view_cont roller.h" 17 #import "ios/chrome/browser/ui/settings/clear_browsing_data_collection_view_cont roller.h"
17 #import "ios/chrome/browser/ui/settings/settings_collection_view_controller.h" 18 #import "ios/chrome/browser/ui/settings/settings_collection_view_controller.h"
18 #import "ios/chrome/browser/ui/tools_menu/tools_menu_view_controller.h" 19 #import "ios/chrome/browser/ui/tools_menu/tools_menu_view_controller.h"
(...skipping 15 matching lines...) Expand all
34 #import "ios/web/public/test/http_server.h" 35 #import "ios/web/public/test/http_server.h"
35 #import "ios/web/public/test/http_server_util.h" 36 #import "ios/web/public/test/http_server_util.h"
36 #import "net/base/mac/url_conversions.h" 37 #import "net/base/mac/url_conversions.h"
37 #include "ui/base/l10n/l10n_util.h" 38 #include "ui/base/l10n/l10n_util.h"
38 39
39 #if !defined(__has_feature) || !__has_feature(objc_arc) 40 #if !defined(__has_feature) || !__has_feature(objc_arc)
40 #error "This file requires ARC support." 41 #error "This file requires ARC support."
41 #endif 42 #endif
42 43
43 using chrome_test_util::ButtonWithAccessibilityLabelId; 44 using chrome_test_util::ButtonWithAccessibilityLabelId;
45 using chrome_test_util::WebViewContainingText;
44 46
45 namespace { 47 namespace {
46 char kURL1[] = "http://firstURL"; 48 char kURL1[] = "http://firstURL";
47 char kURL2[] = "http://secondURL"; 49 char kURL2[] = "http://secondURL";
48 char kURL3[] = "http://thirdURL"; 50 char kURL3[] = "http://thirdURL";
49 char kResponse1[] = "Test Page 1"; 51 char kTitle1[] = "Page 1";
50 char kResponse2[] = "Test Page 2"; 52 char kTitle2[] = "Page 2";
51 char kResponse3[] = "Test Page 3"; 53 char kResponse1[] = "Test Page 1 content";
54 char kResponse2[] = "Test Page 2 content";
55 char kResponse3[] = "Test Page 3 content";
52 56
53 // Matcher for entry in history for URL. 57 // Matcher for entry in history for URL and title.
54 id<GREYMatcher> HistoryEntryWithUrl(const GURL& url) { 58 id<GREYMatcher> HistoryEntry(const GURL& url, const std::string& title) {
55 NSString* url_spec = base::SysUTF8ToNSString(url.spec()); 59 NSString* url_spec_text = base::SysUTF8ToNSString(url.spec());
56 return grey_allOf(grey_text(url_spec), grey_sufficientlyVisible(), nil); 60 NSString* title_text = base::SysUTF8ToNSString(title);
61
62 MatchesBlock matches = ^BOOL(HistoryEntryCell* cell) {
63 return [cell.textLabel.text isEqual:title_text] &&
64 [cell.detailTextLabel.text isEqual:url_spec_text];
65 };
66
67 DescribeToBlock describe = ^(id<GREYDescription> description) {
68 [description appendText:@"view containing URL text: "];
69 [description appendText:url_spec_text];
70 [description appendText:@" title text: "];
71 [description appendText:title_text];
72 };
73
74 return grey_allOf(
75 grey_kindOfClass([HistoryEntryCell class]),
76 [[GREYElementMatcherBlock alloc] initWithMatchesBlock:matches
77 descriptionBlock:describe],
78 grey_sufficientlyVisible(), nil);
57 } 79 }
58 // Matcher for the history button in the tools menu. 80 // Matcher for the history button in the tools menu.
59 id<GREYMatcher> HistoryButton() { 81 id<GREYMatcher> HistoryButton() {
60 return ButtonWithAccessibilityLabelId(IDS_HISTORY_SHOW_HISTORY); 82 return ButtonWithAccessibilityLabelId(IDS_HISTORY_SHOW_HISTORY);
61 } 83 }
62 // Matcher for the done button in the navigation bar. 84 // Matcher for the done button in the navigation bar.
63 id<GREYMatcher> NavigationDoneButton() { 85 id<GREYMatcher> NavigationDoneButton() {
64 // Include sufficientlyVisible condition for the case of the clear browsing 86 // Include sufficientlyVisible condition for the case of the clear browsing
65 // dialog, which also has a "Done" button and is displayed over the history 87 // dialog, which also has a "Done" button and is displayed over the history
66 // panel. 88 // panel.
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 - (void)resetBrowsingDataPrefs; 198 - (void)resetBrowsingDataPrefs;
177 199
178 @end 200 @end
179 201
180 @implementation HistoryUITestCase 202 @implementation HistoryUITestCase
181 203
182 // Set up called once for the class. 204 // Set up called once for the class.
183 + (void)setUp { 205 + (void)setUp {
184 [super setUp]; 206 [super setUp];
185 std::map<GURL, std::string> responses; 207 std::map<GURL, std::string> responses;
186 responses[web::test::HttpServer::MakeUrl(kURL1)] = kResponse1; 208 const char kPageFormat[] = "<head><title>%s</title></head><body>%s</body>";
187 responses[web::test::HttpServer::MakeUrl(kURL2)] = kResponse2; 209 responses[web::test::HttpServer::MakeUrl(kURL1)] =
210 base::StringPrintf(kPageFormat, kTitle1, kResponse1);
211 responses[web::test::HttpServer::MakeUrl(kURL2)] =
212 base::StringPrintf(kPageFormat, kTitle2, kResponse2);
213 // Page 3 does not have <title> tag, so URL will be its title.
188 responses[web::test::HttpServer::MakeUrl(kURL3)] = kResponse3; 214 responses[web::test::HttpServer::MakeUrl(kURL3)] = kResponse3;
189 web::test::SetUpSimpleHttpServer(responses); 215 web::test::SetUpSimpleHttpServer(responses);
190 } 216 }
191 217
192 - (void)setUp { 218 - (void)setUp {
193 [super setUp]; 219 [super setUp];
194 _URL1 = web::test::HttpServer::MakeUrl(kURL1); 220 _URL1 = web::test::HttpServer::MakeUrl(kURL1);
195 _URL2 = web::test::HttpServer::MakeUrl(kURL2); 221 _URL2 = web::test::HttpServer::MakeUrl(kURL2);
196 _URL3 = web::test::HttpServer::MakeUrl(kURL3); 222 _URL3 = web::test::HttpServer::MakeUrl(kURL3);
197 [ChromeEarlGrey clearBrowsingHistory]; 223 [ChromeEarlGrey clearBrowsingHistory];
(...skipping 27 matching lines...) Expand all
225 [self openHistoryPanel]; 251 [self openHistoryPanel];
226 [self assertNoHistoryShown]; 252 [self assertNoHistoryShown];
227 } 253 }
228 254
229 // Tests that the history panel displays navigation history. 255 // Tests that the history panel displays navigation history.
230 - (void)testDisplayHistory { 256 - (void)testDisplayHistory {
231 [self loadTestURLs]; 257 [self loadTestURLs];
232 [self openHistoryPanel]; 258 [self openHistoryPanel];
233 259
234 // Assert that history displays three entries. 260 // Assert that history displays three entries.
235 [[EarlGrey selectElementWithMatcher:HistoryEntryWithUrl(_URL1)] 261 [[EarlGrey selectElementWithMatcher:HistoryEntry(_URL1, kTitle1)]
236 assertWithMatcher:grey_notNil()]; 262 assertWithMatcher:grey_notNil()];
237 [[EarlGrey selectElementWithMatcher:HistoryEntryWithUrl(_URL2)] 263 [[EarlGrey selectElementWithMatcher:HistoryEntry(_URL2, kTitle2)]
238 assertWithMatcher:grey_notNil()]; 264 assertWithMatcher:grey_notNil()];
239 [[EarlGrey selectElementWithMatcher:HistoryEntryWithUrl(_URL3)] 265 [[EarlGrey selectElementWithMatcher:HistoryEntry(_URL3, _URL3.GetContent())]
240 assertWithMatcher:grey_notNil()]; 266 assertWithMatcher:grey_notNil()];
241 267
242 // Tap a history entry and assert that navigation to that entry's URL occurs. 268 // Tap a history entry and assert that navigation to that entry's URL occurs.
243 [[EarlGrey selectElementWithMatcher:HistoryEntryWithUrl(_URL1)] 269 [[EarlGrey selectElementWithMatcher:HistoryEntry(_URL1, kTitle1)]
244 performAction:grey_tap()]; 270 performAction:grey_tap()];
245 id<GREYMatcher> webViewMatcher = 271 [[EarlGrey selectElementWithMatcher:WebViewContainingText(kResponse1)]
246 chrome_test_util::WebViewContainingText(kResponse1);
247 [[EarlGrey selectElementWithMatcher:webViewMatcher]
248 assertWithMatcher:grey_notNil()]; 272 assertWithMatcher:grey_notNil()];
249 } 273 }
250 274
275 // Tests that history is not changed after performing back navigation.
276 // TODO(crbug.com/688047): Enable this test.
277 - (void)DISABLED_testHistoryUpdateAfterBackNavigation {
278 [ChromeEarlGrey loadURL:_URL1];
279 [ChromeEarlGrey loadURL:_URL2];
280
281 [[EarlGrey selectElementWithMatcher:chrome_test_util::BackButton()]
282 performAction:grey_tap()];
283 [[EarlGrey selectElementWithMatcher:WebViewContainingText(kResponse1)]
284 assertWithMatcher:grey_notNil()];
285
286 [self openHistoryPanel];
287
288 [[EarlGrey selectElementWithMatcher:HistoryEntry(_URL1, kTitle1)]
289 assertWithMatcher:grey_notNil()];
290 [[EarlGrey selectElementWithMatcher:HistoryEntry(_URL2, kTitle2)]
291 assertWithMatcher:grey_notNil()];
292 }
293
251 // Test that history displays a message about entries only if the user is logged 294 // Test that history displays a message about entries only if the user is logged
252 // in, and that tapping on the link in the message opens a new tab with the sync 295 // in, and that tapping on the link in the message opens a new tab with the sync
253 // help page. 296 // help page.
254 - (void)testHistoryEntriesStatusCell { 297 - (void)testHistoryEntriesStatusCell {
255 [self loadTestURLs]; 298 [self loadTestURLs];
256 [self openHistoryPanel]; 299 [self openHistoryPanel];
257 // Assert that no message is shown when the user is not signed in. 300 // Assert that no message is shown when the user is not signed in.
258 NSRange range; 301 NSRange range;
259 NSString* entriesMessage = ParseStringWithLink( 302 NSString* entriesMessage = ParseStringWithLink(
260 l10n_util::GetNSString(IDS_IOS_HISTORY_NO_SYNCED_RESULTS), &range); 303 l10n_util::GetNSString(IDS_IOS_HISTORY_NO_SYNCED_RESULTS), &range);
261 [[EarlGrey selectElementWithMatcher:grey_text(entriesMessage)] 304 [[EarlGrey selectElementWithMatcher:grey_text(entriesMessage)]
262 assertWithMatcher:grey_nil()]; 305 assertWithMatcher:grey_nil()];
263 [[EarlGrey selectElementWithMatcher:NavigationDoneButton()] 306 [[EarlGrey selectElementWithMatcher:NavigationDoneButton()]
264 performAction:grey_tap()]; 307 performAction:grey_tap()];
265 308
266 // Sign in and assert that the page indicates what type of history entries 309 // Sign in and assert that the page indicates what type of history entries
267 // are shown. 310 // are shown.
268 MockSignIn(); 311 MockSignIn();
269 [self openHistoryPanel]; 312 [self openHistoryPanel];
270 // Assert that message about entries is shown. The "history is showing local 313 // Assert that message about entries is shown. The "history is showing local
271 // entries" message will be shown because sync is not set up for this test. 314 // entries" message will be shown because sync is not set up for this test.
272 [[EarlGrey selectElementWithMatcher:grey_text(entriesMessage)] 315 [[EarlGrey selectElementWithMatcher:grey_text(entriesMessage)]
273 assertWithMatcher:grey_notNil()]; 316 assertWithMatcher:grey_notNil()];
274 317
275 // Tap on "Learn more" link and assert that new tab with the link is opened. 318 // Tap on "Learn more" link and assert that new tab with the link is opened.
276 [[EarlGrey 319 [[EarlGrey
277 selectElementWithMatcher:grey_kindOfClass([TransparentLinkButton class])] 320 selectElementWithMatcher:grey_kindOfClass([TransparentLinkButton class])]
278 performAction:grey_tap()]; 321 performAction:grey_tap()];
279 chrome_test_util::AssertMainTabCount(2); 322 chrome_test_util::AssertMainTabCount(2);
280 id<GREYMatcher> webViewMatcher = chrome_test_util::WebViewContainingText( 323 id<GREYMatcher> webViewMatcher =
281 "Sync and view tabs and history across devices"); 324 WebViewContainingText("Sync and view tabs and history across devices");
282 [[EarlGrey selectElementWithMatcher:webViewMatcher] 325 [[EarlGrey selectElementWithMatcher:webViewMatcher]
283 assertWithMatcher:grey_notNil()]; 326 assertWithMatcher:grey_notNil()];
284 } 327 }
285 328
286 // Tests that searching history displays only entries matching the search term. 329 // Tests that searching history displays only entries matching the search term.
287 - (void)testSearchHistory { 330 - (void)testSearchHistory {
288 [self loadTestURLs]; 331 [self loadTestURLs];
289 [self openHistoryPanel]; 332 [self openHistoryPanel];
290 [[EarlGrey selectElementWithMatcher:SearchIconButton()] 333 [[EarlGrey selectElementWithMatcher:SearchIconButton()]
291 performAction:grey_tap()]; 334 performAction:grey_tap()];
292 335
293 NSString* searchString = 336 NSString* searchString =
294 [NSString stringWithFormat:@"%s", _URL1.path().c_str()]; 337 [NSString stringWithFormat:@"%s", _URL1.path().c_str()];
295 [[EarlGrey selectElementWithMatcher:grey_keyWindow()] 338 [[EarlGrey selectElementWithMatcher:grey_keyWindow()]
296 performAction:grey_typeText(searchString)]; 339 performAction:grey_typeText(searchString)];
297 [[EarlGrey selectElementWithMatcher:HistoryEntryWithUrl(_URL1)] 340 [[EarlGrey selectElementWithMatcher:HistoryEntry(_URL1, kTitle1)]
298 assertWithMatcher:grey_notNil()]; 341 assertWithMatcher:grey_notNil()];
299 [[EarlGrey selectElementWithMatcher:HistoryEntryWithUrl(_URL2)] 342 [[EarlGrey selectElementWithMatcher:HistoryEntry(_URL2, kTitle2)]
300 assertWithMatcher:grey_nil()]; 343 assertWithMatcher:grey_nil()];
301 [[EarlGrey selectElementWithMatcher:HistoryEntryWithUrl(_URL3)] 344 [[EarlGrey selectElementWithMatcher:HistoryEntry(_URL3, _URL3.GetContent())]
302 assertWithMatcher:grey_nil()]; 345 assertWithMatcher:grey_nil()];
303 } 346 }
304 347
305 // Tests deletion of history entries. 348 // Tests deletion of history entries.
306 - (void)testDeleteHistory { 349 - (void)testDeleteHistory {
307 [self loadTestURLs]; 350 [self loadTestURLs];
308 [self openHistoryPanel]; 351 [self openHistoryPanel];
309 352
310 // Assert that three history elements are present. 353 // Assert that three history elements are present.
311 [[EarlGrey selectElementWithMatcher:HistoryEntryWithUrl(_URL1)] 354 [[EarlGrey selectElementWithMatcher:HistoryEntry(_URL1, kTitle1)]
312 assertWithMatcher:grey_notNil()]; 355 assertWithMatcher:grey_notNil()];
313 [[EarlGrey selectElementWithMatcher:HistoryEntryWithUrl(_URL2)] 356 [[EarlGrey selectElementWithMatcher:HistoryEntry(_URL2, kTitle2)]
314 assertWithMatcher:grey_notNil()]; 357 assertWithMatcher:grey_notNil()];
315 [[EarlGrey selectElementWithMatcher:HistoryEntryWithUrl(_URL3)] 358 [[EarlGrey selectElementWithMatcher:HistoryEntry(_URL3, _URL3.GetContent())]
316 assertWithMatcher:grey_notNil()]; 359 assertWithMatcher:grey_notNil()];
317 360
318 // Enter edit mode, select a history element, and press delete. 361 // Enter edit mode, select a history element, and press delete.
319 [[EarlGrey selectElementWithMatcher:NavigationEditButton()] 362 [[EarlGrey selectElementWithMatcher:NavigationEditButton()]
320 performAction:grey_tap()]; 363 performAction:grey_tap()];
321 [[EarlGrey selectElementWithMatcher:HistoryEntryWithUrl(_URL1)] 364 [[EarlGrey selectElementWithMatcher:HistoryEntry(_URL1, kTitle1)]
322 performAction:grey_tap()]; 365 performAction:grey_tap()];
323 [[EarlGrey selectElementWithMatcher:DeleteHistoryEntriesButton()] 366 [[EarlGrey selectElementWithMatcher:DeleteHistoryEntriesButton()]
324 performAction:grey_tap()]; 367 performAction:grey_tap()];
325 368
326 // Assert that the deleted entry is gone and the other two remain. 369 // Assert that the deleted entry is gone and the other two remain.
327 [[EarlGrey selectElementWithMatcher:HistoryEntryWithUrl(_URL1)] 370 [[EarlGrey selectElementWithMatcher:HistoryEntry(_URL1, kTitle1)]
328 assertWithMatcher:grey_nil()]; 371 assertWithMatcher:grey_nil()];
329 [[EarlGrey selectElementWithMatcher:HistoryEntryWithUrl(_URL2)] 372 [[EarlGrey selectElementWithMatcher:HistoryEntry(_URL2, kTitle2)]
330 assertWithMatcher:grey_notNil()]; 373 assertWithMatcher:grey_notNil()];
331 [[EarlGrey selectElementWithMatcher:HistoryEntryWithUrl(_URL3)] 374 [[EarlGrey selectElementWithMatcher:HistoryEntry(_URL3, _URL3.GetContent())]
332 assertWithMatcher:grey_notNil()]; 375 assertWithMatcher:grey_notNil()];
333 376
334 // Enter edit mode, select both remaining entries, and press delete. 377 // Enter edit mode, select both remaining entries, and press delete.
335 [[EarlGrey selectElementWithMatcher:NavigationEditButton()] 378 [[EarlGrey selectElementWithMatcher:NavigationEditButton()]
336 performAction:grey_tap()]; 379 performAction:grey_tap()];
337 [[EarlGrey selectElementWithMatcher:HistoryEntryWithUrl(_URL2)] 380 [[EarlGrey selectElementWithMatcher:HistoryEntry(_URL2, kTitle2)]
338 performAction:grey_tap()]; 381 performAction:grey_tap()];
339 [[EarlGrey selectElementWithMatcher:HistoryEntryWithUrl(_URL3)] 382 [[EarlGrey selectElementWithMatcher:HistoryEntry(_URL3, _URL3.GetContent())]
340 performAction:grey_tap()]; 383 performAction:grey_tap()];
341 [[EarlGrey selectElementWithMatcher:DeleteHistoryEntriesButton()] 384 [[EarlGrey selectElementWithMatcher:DeleteHistoryEntriesButton()]
342 performAction:grey_tap()]; 385 performAction:grey_tap()];
343 386
344 [self assertNoHistoryShown]; 387 [self assertNoHistoryShown];
345 } 388 }
346 389
347 // Tests clear browsing history. 390 // Tests clear browsing history.
348 - (void)testClearBrowsingHistory { 391 - (void)testClearBrowsingHistory {
349 [self loadTestURLs]; 392 [self loadTestURLs];
(...skipping 26 matching lines...) Expand all
376 [self assertNoHistoryShown]; 419 [self assertNoHistoryShown];
377 } 420 }
378 421
379 // Tests display and selection of 'Open in New Tab' in a context menu on a 422 // Tests display and selection of 'Open in New Tab' in a context menu on a
380 // history entry. 423 // history entry.
381 - (void)testContextMenuOpenInNewTab { 424 - (void)testContextMenuOpenInNewTab {
382 [self loadTestURLs]; 425 [self loadTestURLs];
383 [self openHistoryPanel]; 426 [self openHistoryPanel];
384 427
385 // Long press on the history element. 428 // Long press on the history element.
386 [[EarlGrey selectElementWithMatcher:HistoryEntryWithUrl(_URL1)] 429 [[EarlGrey selectElementWithMatcher:HistoryEntry(_URL1, kTitle1)]
387 performAction:grey_longPress()]; 430 performAction:grey_longPress()];
388 431
389 // Select "Open in New Tab" and confirm that new tab is opened with selected 432 // Select "Open in New Tab" and confirm that new tab is opened with selected
390 // URL. 433 // URL.
391 [[EarlGrey selectElementWithMatcher:OpenInNewTabButton()] 434 [[EarlGrey selectElementWithMatcher:OpenInNewTabButton()]
392 performAction:grey_tap()]; 435 performAction:grey_tap()];
393 [[EarlGrey selectElementWithMatcher:chrome_test_util::OmniboxText( 436 [[EarlGrey selectElementWithMatcher:chrome_test_util::OmniboxText(
394 _URL1.GetContent())] 437 _URL1.GetContent())]
395 assertWithMatcher:grey_notNil()]; 438 assertWithMatcher:grey_notNil()];
396 chrome_test_util::AssertMainTabCount(2); 439 chrome_test_util::AssertMainTabCount(2);
397 } 440 }
398 441
399 // Tests display and selection of 'Open in New Incognito Tab' in a context menu 442 // Tests display and selection of 'Open in New Incognito Tab' in a context menu
400 // on a history entry. 443 // on a history entry.
401 - (void)testContextMenuOpenInNewIncognitoTab { 444 - (void)testContextMenuOpenInNewIncognitoTab {
402 [self loadTestURLs]; 445 [self loadTestURLs];
403 [self openHistoryPanel]; 446 [self openHistoryPanel];
404 447
405 // Long press on the history element. 448 // Long press on the history element.
406 [[EarlGrey selectElementWithMatcher:HistoryEntryWithUrl(_URL1)] 449 [[EarlGrey selectElementWithMatcher:HistoryEntry(_URL1, kTitle1)]
407 performAction:grey_longPress()]; 450 performAction:grey_longPress()];
408 451
409 // Select "Open in New Incognito Tab" and confirm that new tab is opened in 452 // Select "Open in New Incognito Tab" and confirm that new tab is opened in
410 // incognito with the selected URL. 453 // incognito with the selected URL.
411 [[EarlGrey selectElementWithMatcher:OpenInNewIncognitoTabButton()] 454 [[EarlGrey selectElementWithMatcher:OpenInNewIncognitoTabButton()]
412 performAction:grey_tap()]; 455 performAction:grey_tap()];
413 [[EarlGrey selectElementWithMatcher:chrome_test_util::OmniboxText( 456 [[EarlGrey selectElementWithMatcher:chrome_test_util::OmniboxText(
414 _URL1.GetContent())] 457 _URL1.GetContent())]
415 assertWithMatcher:grey_notNil()]; 458 assertWithMatcher:grey_notNil()];
416 chrome_test_util::AssertMainTabCount(1); 459 chrome_test_util::AssertMainTabCount(1);
417 chrome_test_util::AssertIncognitoTabCount(1); 460 chrome_test_util::AssertIncognitoTabCount(1);
418 } 461 }
419 462
420 // Tests display and selection of 'Copy URL' in a context menu on a history 463 // Tests display and selection of 'Copy URL' in a context menu on a history
421 // entry. 464 // entry.
422 - (void)testContextMenuCopy { 465 - (void)testContextMenuCopy {
423 ProceduralBlock clearPasteboard = ^{ 466 ProceduralBlock clearPasteboard = ^{
424 [[UIPasteboard generalPasteboard] setURLs:nil]; 467 [[UIPasteboard generalPasteboard] setURLs:nil];
425 }; 468 };
426 [self setTearDownHandler:clearPasteboard]; 469 [self setTearDownHandler:clearPasteboard];
427 clearPasteboard(); 470 clearPasteboard();
428 471
429 [self loadTestURLs]; 472 [self loadTestURLs];
430 [self openHistoryPanel]; 473 [self openHistoryPanel];
431 474
432 // Long press on the history element. 475 // Long press on the history element.
433 [[EarlGrey selectElementWithMatcher:HistoryEntryWithUrl(_URL1)] 476 [[EarlGrey selectElementWithMatcher:HistoryEntry(_URL1, kTitle1)]
434 performAction:grey_longPress()]; 477 performAction:grey_longPress()];
435 478
436 // Tap "Copy URL" and wait for the URL to be copied to the pasteboard. 479 // Tap "Copy URL" and wait for the URL to be copied to the pasteboard.
437 [[EarlGrey selectElementWithMatcher:CopyUrlButton()] 480 [[EarlGrey selectElementWithMatcher:CopyUrlButton()]
438 performAction:grey_tap()]; 481 performAction:grey_tap()];
439 bool success = 482 bool success =
440 testing::WaitUntilConditionOrTimeout(testing::kWaitForUIElementTimeout, ^{ 483 testing::WaitUntilConditionOrTimeout(testing::kWaitForUIElementTimeout, ^{
441 return _URL1 == 484 return _URL1 ==
442 net::GURLWithNSURL([UIPasteboard generalPasteboard].URL); 485 net::GURLWithNSURL([UIPasteboard generalPasteboard].URL);
443 }); 486 });
444 GREYAssertTrue(success, @"Pasteboard URL was not set to %s", 487 GREYAssertTrue(success, @"Pasteboard URL was not set to %s",
445 _URL1.spec().c_str()); 488 _URL1.spec().c_str());
446 } 489 }
447 490
448 // Navigates to history and checks elements for accessibility. 491 // Navigates to history and checks elements for accessibility.
449 - (void)testAccessibilityOnHistory { 492 - (void)testAccessibilityOnHistory {
450 [self openHistoryPanel]; 493 [self openHistoryPanel];
451 chrome_test_util::VerifyAccessibilityForCurrentScreen(); 494 chrome_test_util::VerifyAccessibilityForCurrentScreen();
452 // Close history. 495 // Close history.
453 [[EarlGrey 496 [[EarlGrey
454 selectElementWithMatcher:chrome_test_util::ButtonWithAccessibilityLabelId( 497 selectElementWithMatcher:chrome_test_util::ButtonWithAccessibilityLabelId(
455 IDS_IOS_NAVIGATION_BAR_DONE_BUTTON)] 498 IDS_IOS_NAVIGATION_BAR_DONE_BUTTON)]
456 performAction:grey_tap()]; 499 performAction:grey_tap()];
457 } 500 }
458 501
459 #pragma mark Helper Methods 502 #pragma mark Helper Methods
460 503
461 - (void)loadTestURLs { 504 - (void)loadTestURLs {
462 [ChromeEarlGrey loadURL:_URL1]; 505 [ChromeEarlGrey loadURL:_URL1];
463 id<GREYMatcher> response1Matcher = 506 [[EarlGrey selectElementWithMatcher:WebViewContainingText(kResponse1)]
464 chrome_test_util::WebViewContainingText(kResponse1);
465 [[EarlGrey selectElementWithMatcher:response1Matcher]
466 assertWithMatcher:grey_notNil()]; 507 assertWithMatcher:grey_notNil()];
467 508
468 [ChromeEarlGrey loadURL:_URL2]; 509 [ChromeEarlGrey loadURL:_URL2];
469 id<GREYMatcher> response2Matcher = 510 [[EarlGrey selectElementWithMatcher:WebViewContainingText(kResponse2)]
470 chrome_test_util::WebViewContainingText(kResponse2);
471 [[EarlGrey selectElementWithMatcher:response2Matcher]
472 assertWithMatcher:grey_notNil()]; 511 assertWithMatcher:grey_notNil()];
473 512
474 [ChromeEarlGrey loadURL:_URL3]; 513 [ChromeEarlGrey loadURL:_URL3];
475 id<GREYMatcher> response3Matcher = 514 [[EarlGrey selectElementWithMatcher:WebViewContainingText(kResponse3)]
476 chrome_test_util::WebViewContainingText(kResponse3);
477 [[EarlGrey selectElementWithMatcher:response3Matcher]
478 assertWithMatcher:grey_notNil()]; 515 assertWithMatcher:grey_notNil()];
479 } 516 }
480 517
481 - (void)openHistoryPanel { 518 - (void)openHistoryPanel {
482 [ChromeEarlGreyUI openToolsMenu]; 519 [ChromeEarlGreyUI openToolsMenu];
483 [[EarlGrey selectElementWithMatcher:HistoryButton()] 520 [[EarlGrey selectElementWithMatcher:HistoryButton()]
484 performAction:grey_tap()]; 521 performAction:grey_tap()];
485 } 522 }
486 523
487 - (void)assertNoHistoryShown { 524 - (void)assertNoHistoryShown {
(...skipping 13 matching lines...) Expand all
501 - (void)resetBrowsingDataPrefs { 538 - (void)resetBrowsingDataPrefs {
502 PrefService* prefs = chrome_test_util::GetOriginalBrowserState()->GetPrefs(); 539 PrefService* prefs = chrome_test_util::GetOriginalBrowserState()->GetPrefs();
503 prefs->ClearPref(browsing_data::prefs::kDeleteBrowsingHistory); 540 prefs->ClearPref(browsing_data::prefs::kDeleteBrowsingHistory);
504 prefs->ClearPref(browsing_data::prefs::kDeleteCookies); 541 prefs->ClearPref(browsing_data::prefs::kDeleteCookies);
505 prefs->ClearPref(browsing_data::prefs::kDeleteCache); 542 prefs->ClearPref(browsing_data::prefs::kDeleteCache);
506 prefs->ClearPref(browsing_data::prefs::kDeletePasswords); 543 prefs->ClearPref(browsing_data::prefs::kDeletePasswords);
507 prefs->ClearPref(browsing_data::prefs::kDeleteFormData); 544 prefs->ClearPref(browsing_data::prefs::kDeleteFormData);
508 } 545 }
509 546
510 @end 547 @end
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698