| 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/sys_string_conversions.h" | 9 #include "base/strings/sys_string_conversions.h" |
| 10 #include "components/browsing_data/core/pref_names.h" | 10 #include "components/browsing_data/core/pref_names.h" |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 // Some tests change the default values for the "Clear Browsing Data" settings | 211 // Some tests change the default values for the "Clear Browsing Data" settings |
| 212 // screen. | 212 // screen. |
| 213 [self resetBrowsingDataPrefs]; | 213 [self resetBrowsingDataPrefs]; |
| 214 [super tearDown]; | 214 [super tearDown]; |
| 215 } | 215 } |
| 216 | 216 |
| 217 #pragma mark Tests | 217 #pragma mark Tests |
| 218 | 218 |
| 219 // Tests that no history is shown if there has been no navigation. | 219 // Tests that no history is shown if there has been no navigation. |
| 220 - (void)testDisplayNoHistory { | 220 - (void)testDisplayNoHistory { |
| 221 // TODO(crbug.com/685570): Fix the tap instead of adding a delay. | |
| 222 GREYCondition* myCondition = [GREYCondition | |
| 223 conditionWithName:@"Delay to ensure the toolbar menu can be opened" | |
| 224 block:^BOOL { | |
| 225 return NO; | |
| 226 }]; | |
| 227 [myCondition waitWithTimeout:0.5]; | |
| 228 | |
| 229 [self openHistoryPanel]; | 221 [self openHistoryPanel]; |
| 230 [self assertNoHistoryShown]; | 222 [self assertNoHistoryShown]; |
| 231 } | 223 } |
| 232 | 224 |
| 233 // Tests that the history panel displays navigation history. | 225 // Tests that the history panel displays navigation history. |
| 234 - (void)testDisplayHistory { | 226 - (void)testDisplayHistory { |
| 235 [self loadTestURLs]; | 227 [self loadTestURLs]; |
| 236 [self openHistoryPanel]; | 228 [self openHistoryPanel]; |
| 237 | 229 |
| 238 // Assert that history displays three entries. | 230 // Assert that history displays three entries. |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 testing::WaitUntilConditionOrTimeout(testing::kWaitForUIElementTimeout, ^{ | 436 testing::WaitUntilConditionOrTimeout(testing::kWaitForUIElementTimeout, ^{ |
| 445 return _URL1 == | 437 return _URL1 == |
| 446 net::GURLWithNSURL([UIPasteboard generalPasteboard].URL); | 438 net::GURLWithNSURL([UIPasteboard generalPasteboard].URL); |
| 447 }); | 439 }); |
| 448 GREYAssertTrue(success, @"Pasteboard URL was not set to %s", | 440 GREYAssertTrue(success, @"Pasteboard URL was not set to %s", |
| 449 _URL1.spec().c_str()); | 441 _URL1.spec().c_str()); |
| 450 } | 442 } |
| 451 | 443 |
| 452 // Navigates to history and checks elements for accessibility. | 444 // Navigates to history and checks elements for accessibility. |
| 453 - (void)testAccessibilityOnHistory { | 445 - (void)testAccessibilityOnHistory { |
| 454 // TODO(crbug.com/685570): Fix the tap instead of adding a delay. | |
| 455 GREYCondition* myCondition = [GREYCondition | |
| 456 conditionWithName:@"Delay to ensure the toolbar menu can be opened" | |
| 457 block:^BOOL { | |
| 458 return NO; | |
| 459 }]; | |
| 460 [myCondition waitWithTimeout:0.5]; | |
| 461 | |
| 462 [self openHistoryPanel]; | 446 [self openHistoryPanel]; |
| 463 chrome_test_util::VerifyAccessibilityForCurrentScreen(); | 447 chrome_test_util::VerifyAccessibilityForCurrentScreen(); |
| 464 // Close history. | 448 // Close history. |
| 465 [[EarlGrey | 449 [[EarlGrey |
| 466 selectElementWithMatcher:chrome_test_util::ButtonWithAccessibilityLabelId( | 450 selectElementWithMatcher:chrome_test_util::ButtonWithAccessibilityLabelId( |
| 467 IDS_IOS_NAVIGATION_BAR_DONE_BUTTON)] | 451 IDS_IOS_NAVIGATION_BAR_DONE_BUTTON)] |
| 468 performAction:grey_tap()]; | 452 performAction:grey_tap()]; |
| 469 } | 453 } |
| 470 | 454 |
| 471 #pragma mark Helper Methods | 455 #pragma mark Helper Methods |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 513 - (void)resetBrowsingDataPrefs { | 497 - (void)resetBrowsingDataPrefs { |
| 514 PrefService* prefs = chrome_test_util::GetOriginalBrowserState()->GetPrefs(); | 498 PrefService* prefs = chrome_test_util::GetOriginalBrowserState()->GetPrefs(); |
| 515 prefs->ClearPref(browsing_data::prefs::kDeleteBrowsingHistory); | 499 prefs->ClearPref(browsing_data::prefs::kDeleteBrowsingHistory); |
| 516 prefs->ClearPref(browsing_data::prefs::kDeleteCookies); | 500 prefs->ClearPref(browsing_data::prefs::kDeleteCookies); |
| 517 prefs->ClearPref(browsing_data::prefs::kDeleteCache); | 501 prefs->ClearPref(browsing_data::prefs::kDeleteCache); |
| 518 prefs->ClearPref(browsing_data::prefs::kDeletePasswords); | 502 prefs->ClearPref(browsing_data::prefs::kDeletePasswords); |
| 519 prefs->ClearPref(browsing_data::prefs::kDeleteFormData); | 503 prefs->ClearPref(browsing_data::prefs::kDeleteFormData); |
| 520 } | 504 } |
| 521 | 505 |
| 522 @end | 506 @end |
| OLD | NEW |