| OLD | NEW | 
|    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/stringprintf.h" | 
|   10 #include "base/strings/sys_string_conversions.h" |   10 #include "base/strings/sys_string_conversions.h" | 
| (...skipping 26 matching lines...) Expand all  Loading... | 
|   37 #import "net/base/mac/url_conversions.h" |   37 #import "net/base/mac/url_conversions.h" | 
|   38 #include "ui/base/l10n/l10n_util.h" |   38 #include "ui/base/l10n/l10n_util.h" | 
|   39  |   39  | 
|   40 #if !defined(__has_feature) || !__has_feature(objc_arc) |   40 #if !defined(__has_feature) || !__has_feature(objc_arc) | 
|   41 #error "This file requires ARC support." |   41 #error "This file requires ARC support." | 
|   42 #endif |   42 #endif | 
|   43  |   43  | 
|   44 using chrome_test_util::ButtonWithAccessibilityLabelId; |   44 using chrome_test_util::ButtonWithAccessibilityLabelId; | 
|   45 using chrome_test_util::NavigationBarDoneButton; |   45 using chrome_test_util::NavigationBarDoneButton; | 
|   46 using chrome_test_util::OpenLinkInNewTabButton; |   46 using chrome_test_util::OpenLinkInNewTabButton; | 
|   47 using chrome_test_util::WebViewContainingText; |  | 
|   48  |   47  | 
|   49 namespace { |   48 namespace { | 
|   50 char kURL1[] = "http://firstURL"; |   49 char kURL1[] = "http://firstURL"; | 
|   51 char kURL2[] = "http://secondURL"; |   50 char kURL2[] = "http://secondURL"; | 
|   52 char kURL3[] = "http://thirdURL"; |   51 char kURL3[] = "http://thirdURL"; | 
|   53 char kTitle1[] = "Page 1"; |   52 char kTitle1[] = "Page 1"; | 
|   54 char kTitle2[] = "Page 2"; |   53 char kTitle2[] = "Page 2"; | 
|   55 char kResponse1[] = "Test Page 1 content"; |   54 char kResponse1[] = "Test Page 1 content"; | 
|   56 char kResponse2[] = "Test Page 2 content"; |   55 char kResponse2[] = "Test Page 2 content"; | 
|   57 char kResponse3[] = "Test Page 3 content"; |   56 char kResponse3[] = "Test Page 3 content"; | 
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  246   [[EarlGrey selectElementWithMatcher:HistoryEntry(_URL1, kTitle1)] |  245   [[EarlGrey selectElementWithMatcher:HistoryEntry(_URL1, kTitle1)] | 
|  247       assertWithMatcher:grey_notNil()]; |  246       assertWithMatcher:grey_notNil()]; | 
|  248   [[EarlGrey selectElementWithMatcher:HistoryEntry(_URL2, kTitle2)] |  247   [[EarlGrey selectElementWithMatcher:HistoryEntry(_URL2, kTitle2)] | 
|  249       assertWithMatcher:grey_notNil()]; |  248       assertWithMatcher:grey_notNil()]; | 
|  250   [[EarlGrey selectElementWithMatcher:HistoryEntry(_URL3, _URL3.GetContent())] |  249   [[EarlGrey selectElementWithMatcher:HistoryEntry(_URL3, _URL3.GetContent())] | 
|  251       assertWithMatcher:grey_notNil()]; |  250       assertWithMatcher:grey_notNil()]; | 
|  252  |  251  | 
|  253   // Tap a history entry and assert that navigation to that entry's URL occurs. |  252   // Tap a history entry and assert that navigation to that entry's URL occurs. | 
|  254   [[EarlGrey selectElementWithMatcher:HistoryEntry(_URL1, kTitle1)] |  253   [[EarlGrey selectElementWithMatcher:HistoryEntry(_URL1, kTitle1)] | 
|  255       performAction:grey_tap()]; |  254       performAction:grey_tap()]; | 
|  256   [[EarlGrey selectElementWithMatcher:WebViewContainingText(kResponse1)] |  255   [ChromeEarlGrey waitForWebViewContainingText:kResponse1]; | 
|  257       assertWithMatcher:grey_notNil()]; |  | 
|  258 } |  256 } | 
|  259  |  257  | 
|  260 // Tests that history is not changed after performing back navigation. |  258 // Tests that history is not changed after performing back navigation. | 
|  261 - (void)testHistoryUpdateAfterBackNavigation { |  259 - (void)testHistoryUpdateAfterBackNavigation { | 
|  262   [ChromeEarlGrey loadURL:_URL1]; |  260   [ChromeEarlGrey loadURL:_URL1]; | 
|  263   [ChromeEarlGrey loadURL:_URL2]; |  261   [ChromeEarlGrey loadURL:_URL2]; | 
|  264  |  262  | 
|  265   [[EarlGrey selectElementWithMatcher:chrome_test_util::BackButton()] |  263   [[EarlGrey selectElementWithMatcher:chrome_test_util::BackButton()] | 
|  266       performAction:grey_tap()]; |  264       performAction:grey_tap()]; | 
|  267   [[EarlGrey selectElementWithMatcher:WebViewContainingText(kResponse1)] |  265   [ChromeEarlGrey waitForWebViewContainingText:kResponse1]; | 
|  268       assertWithMatcher:grey_notNil()]; |  | 
|  269  |  266  | 
|  270   [self openHistoryPanel]; |  267   [self openHistoryPanel]; | 
|  271  |  268  | 
|  272   [[EarlGrey selectElementWithMatcher:HistoryEntry(_URL1, kTitle1)] |  269   [[EarlGrey selectElementWithMatcher:HistoryEntry(_URL1, kTitle1)] | 
|  273       assertWithMatcher:grey_notNil()]; |  270       assertWithMatcher:grey_notNil()]; | 
|  274   [[EarlGrey selectElementWithMatcher:HistoryEntry(_URL2, kTitle2)] |  271   [[EarlGrey selectElementWithMatcher:HistoryEntry(_URL2, kTitle2)] | 
|  275       assertWithMatcher:grey_notNil()]; |  272       assertWithMatcher:grey_notNil()]; | 
|  276 } |  273 } | 
|  277  |  274  | 
|  278 // Test that history displays a message about entries only if the user is logged |  275 // Test that history displays a message about entries only if the user is logged | 
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  475   chrome_test_util::VerifyAccessibilityForCurrentScreen(); |  472   chrome_test_util::VerifyAccessibilityForCurrentScreen(); | 
|  476   // Close history. |  473   // Close history. | 
|  477   [[EarlGrey selectElementWithMatcher:NavigationBarDoneButton()] |  474   [[EarlGrey selectElementWithMatcher:NavigationBarDoneButton()] | 
|  478       performAction:grey_tap()]; |  475       performAction:grey_tap()]; | 
|  479 } |  476 } | 
|  480  |  477  | 
|  481 #pragma mark Helper Methods |  478 #pragma mark Helper Methods | 
|  482  |  479  | 
|  483 - (void)loadTestURLs { |  480 - (void)loadTestURLs { | 
|  484   [ChromeEarlGrey loadURL:_URL1]; |  481   [ChromeEarlGrey loadURL:_URL1]; | 
|  485   [[EarlGrey selectElementWithMatcher:WebViewContainingText(kResponse1)] |  482   [ChromeEarlGrey waitForWebViewContainingText:kResponse1]; | 
|  486       assertWithMatcher:grey_notNil()]; |  | 
|  487  |  483  | 
|  488   [ChromeEarlGrey loadURL:_URL2]; |  484   [ChromeEarlGrey loadURL:_URL2]; | 
|  489   [[EarlGrey selectElementWithMatcher:WebViewContainingText(kResponse2)] |  485   [ChromeEarlGrey waitForWebViewContainingText:kResponse2]; | 
|  490       assertWithMatcher:grey_notNil()]; |  | 
|  491  |  486  | 
|  492   [ChromeEarlGrey loadURL:_URL3]; |  487   [ChromeEarlGrey loadURL:_URL3]; | 
|  493   [[EarlGrey selectElementWithMatcher:WebViewContainingText(kResponse3)] |  488   [ChromeEarlGrey waitForWebViewContainingText:kResponse3]; | 
|  494       assertWithMatcher:grey_notNil()]; |  | 
|  495 } |  489 } | 
|  496  |  490  | 
|  497 - (void)openHistoryPanel { |  491 - (void)openHistoryPanel { | 
|  498   [ChromeEarlGreyUI openToolsMenu]; |  492   [ChromeEarlGreyUI openToolsMenu]; | 
|  499   [[EarlGrey selectElementWithMatcher:HistoryButton()] |  493   [[EarlGrey selectElementWithMatcher:HistoryButton()] | 
|  500       performAction:grey_tap()]; |  494       performAction:grey_tap()]; | 
|  501 } |  495 } | 
|  502  |  496  | 
|  503 - (void)assertNoHistoryShown { |  497 - (void)assertNoHistoryShown { | 
|  504   id<GREYMatcher> noHistoryMessageMatcher = |  498   id<GREYMatcher> noHistoryMessageMatcher = | 
| (...skipping 12 matching lines...) Expand all  Loading... | 
|  517 - (void)resetBrowsingDataPrefs { |  511 - (void)resetBrowsingDataPrefs { | 
|  518   PrefService* prefs = chrome_test_util::GetOriginalBrowserState()->GetPrefs(); |  512   PrefService* prefs = chrome_test_util::GetOriginalBrowserState()->GetPrefs(); | 
|  519   prefs->ClearPref(browsing_data::prefs::kDeleteBrowsingHistory); |  513   prefs->ClearPref(browsing_data::prefs::kDeleteBrowsingHistory); | 
|  520   prefs->ClearPref(browsing_data::prefs::kDeleteCookies); |  514   prefs->ClearPref(browsing_data::prefs::kDeleteCookies); | 
|  521   prefs->ClearPref(browsing_data::prefs::kDeleteCache); |  515   prefs->ClearPref(browsing_data::prefs::kDeleteCache); | 
|  522   prefs->ClearPref(browsing_data::prefs::kDeletePasswords); |  516   prefs->ClearPref(browsing_data::prefs::kDeletePasswords); | 
|  523   prefs->ClearPref(browsing_data::prefs::kDeleteFormData); |  517   prefs->ClearPref(browsing_data::prefs::kDeleteFormData); | 
|  524 } |  518 } | 
|  525  |  519  | 
|  526 @end |  520 @end | 
| OLD | NEW |