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

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

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