| 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 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 [[EarlGrey selectElementWithMatcher:HistoryEntry(_URL1, kTitle1)] | 278 [[EarlGrey selectElementWithMatcher:HistoryEntry(_URL1, kTitle1)] |
| 279 assertWithMatcher:grey_notNil()]; | 279 assertWithMatcher:grey_notNil()]; |
| 280 [[EarlGrey selectElementWithMatcher:HistoryEntry(_URL2, kTitle2)] | 280 [[EarlGrey selectElementWithMatcher:HistoryEntry(_URL2, kTitle2)] |
| 281 assertWithMatcher:grey_notNil()]; | 281 assertWithMatcher:grey_notNil()]; |
| 282 } | 282 } |
| 283 | 283 |
| 284 // Test that history displays a message about entries only if the user is logged | 284 // Test that history displays a message about entries only if the user is logged |
| 285 // in, and that tapping on the link in the message opens a new tab with the sync | 285 // in, and that tapping on the link in the message opens a new tab with the sync |
| 286 // help page. | 286 // help page. |
| 287 - (void)testHistoryEntriesStatusCell { | 287 - (void)testHistoryEntriesStatusCell { |
| 288 // TODO(crbug.com/709135): Evaluate and re-enable this test if necessary. | |
| 289 #if !TARGET_IPHONE_SIMULATOR | |
| 290 EARL_GREY_TEST_DISABLED(@"Test disabled on device."); | |
| 291 #endif | |
| 292 | |
| 293 [self loadTestURLs]; | 288 [self loadTestURLs]; |
| 294 [self openHistoryPanel]; | 289 [self openHistoryPanel]; |
| 295 // Assert that no message is shown when the user is not signed in. | 290 // Assert that no message is shown when the user is not signed in. |
| 296 NSRange range; | 291 NSRange range; |
| 297 NSString* entriesMessage = ParseStringWithLink( | 292 NSString* entriesMessage = ParseStringWithLink( |
| 298 l10n_util::GetNSString(IDS_IOS_HISTORY_NO_SYNCED_RESULTS), &range); | 293 l10n_util::GetNSString(IDS_IOS_HISTORY_NO_SYNCED_RESULTS), &range); |
| 299 [[EarlGrey selectElementWithMatcher:grey_text(entriesMessage)] | 294 [[EarlGrey selectElementWithMatcher:grey_text(entriesMessage)] |
| 300 assertWithMatcher:grey_nil()]; | 295 assertWithMatcher:grey_nil()]; |
| 301 [[EarlGrey selectElementWithMatcher:NavigationBarDoneButton()] | 296 [[EarlGrey selectElementWithMatcher:NavigationBarDoneButton()] |
| 302 performAction:grey_tap()]; | 297 performAction:grey_tap()]; |
| 303 | 298 |
| 304 // Sign in and assert that the page indicates what type of history entries | 299 // Sign in and assert that the page indicates what type of history entries |
| 305 // are shown. | 300 // are shown. |
| 306 MockSignIn(); | 301 MockSignIn(); |
| 307 [self openHistoryPanel]; | 302 [self openHistoryPanel]; |
| 308 // Assert that message about entries is shown. The "history is showing local | 303 // Assert that message about entries is shown. The "history is showing local |
| 309 // entries" message will be shown because sync is not set up for this test. | 304 // entries" message will be shown because sync is not set up for this test. |
| 310 [[EarlGrey selectElementWithMatcher:grey_text(entriesMessage)] | 305 [[EarlGrey selectElementWithMatcher:grey_text(entriesMessage)] |
| 311 assertWithMatcher:grey_notNil()]; | 306 assertWithMatcher:grey_notNil()]; |
| 312 | 307 |
| 313 // Tap on "Learn more" link and assert that new tab with the link is opened. | 308 // Tap on "Learn more" link. |
| 314 [[EarlGrey | 309 [[EarlGrey |
| 315 selectElementWithMatcher:grey_kindOfClass([TransparentLinkButton class])] | 310 selectElementWithMatcher:grey_kindOfClass([TransparentLinkButton class])] |
| 316 performAction:grey_tap()]; | 311 performAction:grey_tap()]; |
| 312 // Assert that new tab with the link is opened, hence tab count of 2. |
| 317 chrome_test_util::AssertMainTabCount(2); | 313 chrome_test_util::AssertMainTabCount(2); |
| 318 id<GREYMatcher> webViewMatcher = | |
| 319 WebViewContainingText("Sync and view tabs and history across devices"); | |
| 320 [[EarlGrey selectElementWithMatcher:webViewMatcher] | |
| 321 assertWithMatcher:grey_notNil()]; | |
| 322 } | 314 } |
| 323 | 315 |
| 324 // Tests that searching history displays only entries matching the search term. | 316 // Tests that searching history displays only entries matching the search term. |
| 325 - (void)testSearchHistory { | 317 - (void)testSearchHistory { |
| 326 [self loadTestURLs]; | 318 [self loadTestURLs]; |
| 327 [self openHistoryPanel]; | 319 [self openHistoryPanel]; |
| 328 [[EarlGrey selectElementWithMatcher:SearchIconButton()] | 320 [[EarlGrey selectElementWithMatcher:SearchIconButton()] |
| 329 performAction:grey_tap()]; | 321 performAction:grey_tap()]; |
| 330 | 322 |
| 331 NSString* searchString = | 323 NSString* searchString = |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 531 - (void)resetBrowsingDataPrefs { | 523 - (void)resetBrowsingDataPrefs { |
| 532 PrefService* prefs = chrome_test_util::GetOriginalBrowserState()->GetPrefs(); | 524 PrefService* prefs = chrome_test_util::GetOriginalBrowserState()->GetPrefs(); |
| 533 prefs->ClearPref(browsing_data::prefs::kDeleteBrowsingHistory); | 525 prefs->ClearPref(browsing_data::prefs::kDeleteBrowsingHistory); |
| 534 prefs->ClearPref(browsing_data::prefs::kDeleteCookies); | 526 prefs->ClearPref(browsing_data::prefs::kDeleteCookies); |
| 535 prefs->ClearPref(browsing_data::prefs::kDeleteCache); | 527 prefs->ClearPref(browsing_data::prefs::kDeleteCache); |
| 536 prefs->ClearPref(browsing_data::prefs::kDeletePasswords); | 528 prefs->ClearPref(browsing_data::prefs::kDeletePasswords); |
| 537 prefs->ClearPref(browsing_data::prefs::kDeleteFormData); | 529 prefs->ClearPref(browsing_data::prefs::kDeleteFormData); |
| 538 } | 530 } |
| 539 | 531 |
| 540 @end | 532 @end |
| OLD | NEW |