| 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 |
| 221 [self openHistoryPanel]; | 229 [self openHistoryPanel]; |
| 222 [self assertNoHistoryShown]; | 230 [self assertNoHistoryShown]; |
| 223 } | 231 } |
| 224 | 232 |
| 225 // Tests that the history panel displays navigation history. | 233 // Tests that the history panel displays navigation history. |
| 226 - (void)testDisplayHistory { | 234 - (void)testDisplayHistory { |
| 227 [self loadTestURLs]; | 235 [self loadTestURLs]; |
| 228 [self openHistoryPanel]; | 236 [self openHistoryPanel]; |
| 229 | 237 |
| 230 // Assert that history displays three entries. | 238 // Assert that history displays three entries. |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 testing::WaitUntilConditionOrTimeout(testing::kWaitForUIElementTimeout, ^{ | 444 testing::WaitUntilConditionOrTimeout(testing::kWaitForUIElementTimeout, ^{ |
| 437 return _URL1 == | 445 return _URL1 == |
| 438 net::GURLWithNSURL([UIPasteboard generalPasteboard].URL); | 446 net::GURLWithNSURL([UIPasteboard generalPasteboard].URL); |
| 439 }); | 447 }); |
| 440 GREYAssertTrue(success, @"Pasteboard URL was not set to %s", | 448 GREYAssertTrue(success, @"Pasteboard URL was not set to %s", |
| 441 _URL1.spec().c_str()); | 449 _URL1.spec().c_str()); |
| 442 } | 450 } |
| 443 | 451 |
| 444 // Navigates to history and checks elements for accessibility. | 452 // Navigates to history and checks elements for accessibility. |
| 445 - (void)testAccessibilityOnHistory { | 453 - (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 |
| 446 [self openHistoryPanel]; | 462 [self openHistoryPanel]; |
| 447 chrome_test_util::VerifyAccessibilityForCurrentScreen(); | 463 chrome_test_util::VerifyAccessibilityForCurrentScreen(); |
| 448 // Close history. | 464 // Close history. |
| 449 [[EarlGrey | 465 [[EarlGrey |
| 450 selectElementWithMatcher:chrome_test_util::ButtonWithAccessibilityLabelId( | 466 selectElementWithMatcher:chrome_test_util::ButtonWithAccessibilityLabelId( |
| 451 IDS_IOS_NAVIGATION_BAR_DONE_BUTTON)] | 467 IDS_IOS_NAVIGATION_BAR_DONE_BUTTON)] |
| 452 performAction:grey_tap()]; | 468 performAction:grey_tap()]; |
| 453 } | 469 } |
| 454 | 470 |
| 455 #pragma mark Helper Methods | 471 #pragma mark Helper Methods |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 497 - (void)resetBrowsingDataPrefs { | 513 - (void)resetBrowsingDataPrefs { |
| 498 PrefService* prefs = chrome_test_util::GetOriginalBrowserState()->GetPrefs(); | 514 PrefService* prefs = chrome_test_util::GetOriginalBrowserState()->GetPrefs(); |
| 499 prefs->ClearPref(browsing_data::prefs::kDeleteBrowsingHistory); | 515 prefs->ClearPref(browsing_data::prefs::kDeleteBrowsingHistory); |
| 500 prefs->ClearPref(browsing_data::prefs::kDeleteCookies); | 516 prefs->ClearPref(browsing_data::prefs::kDeleteCookies); |
| 501 prefs->ClearPref(browsing_data::prefs::kDeleteCache); | 517 prefs->ClearPref(browsing_data::prefs::kDeleteCache); |
| 502 prefs->ClearPref(browsing_data::prefs::kDeletePasswords); | 518 prefs->ClearPref(browsing_data::prefs::kDeletePasswords); |
| 503 prefs->ClearPref(browsing_data::prefs::kDeleteFormData); | 519 prefs->ClearPref(browsing_data::prefs::kDeleteFormData); |
| 504 } | 520 } |
| 505 | 521 |
| 506 @end | 522 @end |
| OLD | NEW |