| 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 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 | 227 |
| 228 // Some tests change the default values for the "Clear Browsing Data" settings | 228 // Some tests change the default values for the "Clear Browsing Data" settings |
| 229 // screen. | 229 // screen. |
| 230 [self resetBrowsingDataPrefs]; | 230 [self resetBrowsingDataPrefs]; |
| 231 [super tearDown]; | 231 [super tearDown]; |
| 232 } | 232 } |
| 233 | 233 |
| 234 #pragma mark Tests | 234 #pragma mark Tests |
| 235 | 235 |
| 236 // Tests that no history is shown if there has been no navigation. | 236 // Tests that no history is shown if there has been no navigation. |
| 237 - (void)testDisplayNoHistory { | 237 // TODO(crbug.com/704403): Re-enable this test. |
| 238 - (void)DISABLED_testDisplayNoHistory { |
| 238 [self openHistoryPanel]; | 239 [self openHistoryPanel]; |
| 239 [self assertNoHistoryShown]; | 240 [self assertNoHistoryShown]; |
| 240 } | 241 } |
| 241 | 242 |
| 242 // Tests that the history panel displays navigation history. | 243 // Tests that the history panel displays navigation history. |
| 243 - (void)testDisplayHistory { | 244 // TODO(crbug.com/704403): Re-enable this test. |
| 245 - (void)DISABLED_testDisplayHistory { |
| 244 [self loadTestURLs]; | 246 [self loadTestURLs]; |
| 245 [self openHistoryPanel]; | 247 [self openHistoryPanel]; |
| 246 | 248 |
| 247 // Assert that history displays three entries. | 249 // Assert that history displays three entries. |
| 248 [[EarlGrey selectElementWithMatcher:HistoryEntry(_URL1, kTitle1)] | 250 [[EarlGrey selectElementWithMatcher:HistoryEntry(_URL1, kTitle1)] |
| 249 assertWithMatcher:grey_notNil()]; | 251 assertWithMatcher:grey_notNil()]; |
| 250 [[EarlGrey selectElementWithMatcher:HistoryEntry(_URL2, kTitle2)] | 252 [[EarlGrey selectElementWithMatcher:HistoryEntry(_URL2, kTitle2)] |
| 251 assertWithMatcher:grey_notNil()]; | 253 assertWithMatcher:grey_notNil()]; |
| 252 [[EarlGrey selectElementWithMatcher:HistoryEntry(_URL3, _URL3.GetContent())] | 254 [[EarlGrey selectElementWithMatcher:HistoryEntry(_URL3, _URL3.GetContent())] |
| 253 assertWithMatcher:grey_notNil()]; | 255 assertWithMatcher:grey_notNil()]; |
| 254 | 256 |
| 255 // Tap a history entry and assert that navigation to that entry's URL occurs. | 257 // Tap a history entry and assert that navigation to that entry's URL occurs. |
| 256 [[EarlGrey selectElementWithMatcher:HistoryEntry(_URL1, kTitle1)] | 258 [[EarlGrey selectElementWithMatcher:HistoryEntry(_URL1, kTitle1)] |
| 257 performAction:grey_tap()]; | 259 performAction:grey_tap()]; |
| 258 [[EarlGrey selectElementWithMatcher:WebViewContainingText(kResponse1)] | 260 [[EarlGrey selectElementWithMatcher:WebViewContainingText(kResponse1)] |
| 259 assertWithMatcher:grey_notNil()]; | 261 assertWithMatcher:grey_notNil()]; |
| 260 } | 262 } |
| 261 | 263 |
| 262 // Tests that history is not changed after performing back navigation. | 264 // Tests that history is not changed after performing back navigation. |
| 263 - (void)testHistoryUpdateAfterBackNavigation { | 265 // TODO(crbug.com/704403): Re-enable this test. |
| 266 - (void)DISABLED_testHistoryUpdateAfterBackNavigation { |
| 264 [ChromeEarlGrey loadURL:_URL1]; | 267 [ChromeEarlGrey loadURL:_URL1]; |
| 265 [ChromeEarlGrey loadURL:_URL2]; | 268 [ChromeEarlGrey loadURL:_URL2]; |
| 266 | 269 |
| 267 [[EarlGrey selectElementWithMatcher:chrome_test_util::BackButton()] | 270 [[EarlGrey selectElementWithMatcher:chrome_test_util::BackButton()] |
| 268 performAction:grey_tap()]; | 271 performAction:grey_tap()]; |
| 269 [[EarlGrey selectElementWithMatcher:WebViewContainingText(kResponse1)] | 272 [[EarlGrey selectElementWithMatcher:WebViewContainingText(kResponse1)] |
| 270 assertWithMatcher:grey_notNil()]; | 273 assertWithMatcher:grey_notNil()]; |
| 271 | 274 |
| 272 [self openHistoryPanel]; | 275 [self openHistoryPanel]; |
| 273 | 276 |
| 274 [[EarlGrey selectElementWithMatcher:HistoryEntry(_URL1, kTitle1)] | 277 [[EarlGrey selectElementWithMatcher:HistoryEntry(_URL1, kTitle1)] |
| 275 assertWithMatcher:grey_notNil()]; | 278 assertWithMatcher:grey_notNil()]; |
| 276 [[EarlGrey selectElementWithMatcher:HistoryEntry(_URL2, kTitle2)] | 279 [[EarlGrey selectElementWithMatcher:HistoryEntry(_URL2, kTitle2)] |
| 277 assertWithMatcher:grey_notNil()]; | 280 assertWithMatcher:grey_notNil()]; |
| 278 } | 281 } |
| 279 | 282 |
| 280 // Test that history displays a message about entries only if the user is logged | 283 // Test that history displays a message about entries only if the user is logged |
| 281 // in, and that tapping on the link in the message opens a new tab with the sync | 284 // in, and that tapping on the link in the message opens a new tab with the sync |
| 282 // help page. | 285 // help page. |
| 283 - (void)testHistoryEntriesStatusCell { | 286 // TODO(crbug.com/704403): Re-enable this test. |
| 287 - (void)DISABLED_testHistoryEntriesStatusCell { |
| 284 [self loadTestURLs]; | 288 [self loadTestURLs]; |
| 285 [self openHistoryPanel]; | 289 [self openHistoryPanel]; |
| 286 // 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. |
| 287 NSRange range; | 291 NSRange range; |
| 288 NSString* entriesMessage = ParseStringWithLink( | 292 NSString* entriesMessage = ParseStringWithLink( |
| 289 l10n_util::GetNSString(IDS_IOS_HISTORY_NO_SYNCED_RESULTS), &range); | 293 l10n_util::GetNSString(IDS_IOS_HISTORY_NO_SYNCED_RESULTS), &range); |
| 290 [[EarlGrey selectElementWithMatcher:grey_text(entriesMessage)] | 294 [[EarlGrey selectElementWithMatcher:grey_text(entriesMessage)] |
| 291 assertWithMatcher:grey_nil()]; | 295 assertWithMatcher:grey_nil()]; |
| 292 [[EarlGrey selectElementWithMatcher:NavigationBarDoneButton()] | 296 [[EarlGrey selectElementWithMatcher:NavigationBarDoneButton()] |
| 293 performAction:grey_tap()]; | 297 performAction:grey_tap()]; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 306 selectElementWithMatcher:grey_kindOfClass([TransparentLinkButton class])] | 310 selectElementWithMatcher:grey_kindOfClass([TransparentLinkButton class])] |
| 307 performAction:grey_tap()]; | 311 performAction:grey_tap()]; |
| 308 chrome_test_util::AssertMainTabCount(2); | 312 chrome_test_util::AssertMainTabCount(2); |
| 309 id<GREYMatcher> webViewMatcher = | 313 id<GREYMatcher> webViewMatcher = |
| 310 WebViewContainingText("Sync and view tabs and history across devices"); | 314 WebViewContainingText("Sync and view tabs and history across devices"); |
| 311 [[EarlGrey selectElementWithMatcher:webViewMatcher] | 315 [[EarlGrey selectElementWithMatcher:webViewMatcher] |
| 312 assertWithMatcher:grey_notNil()]; | 316 assertWithMatcher:grey_notNil()]; |
| 313 } | 317 } |
| 314 | 318 |
| 315 // Tests that searching history displays only entries matching the search term. | 319 // Tests that searching history displays only entries matching the search term. |
| 316 - (void)testSearchHistory { | 320 // TODO(crbug.com/704403): Re-enable this test. |
| 321 - (void)DISABLED_testSearchHistory { |
| 317 [self loadTestURLs]; | 322 [self loadTestURLs]; |
| 318 [self openHistoryPanel]; | 323 [self openHistoryPanel]; |
| 319 [[EarlGrey selectElementWithMatcher:SearchIconButton()] | 324 [[EarlGrey selectElementWithMatcher:SearchIconButton()] |
| 320 performAction:grey_tap()]; | 325 performAction:grey_tap()]; |
| 321 | 326 |
| 322 NSString* searchString = | 327 NSString* searchString = |
| 323 [NSString stringWithFormat:@"%s", _URL1.path().c_str()]; | 328 [NSString stringWithFormat:@"%s", _URL1.path().c_str()]; |
| 324 [[EarlGrey selectElementWithMatcher:grey_keyWindow()] | 329 [[EarlGrey selectElementWithMatcher:grey_keyWindow()] |
| 325 performAction:grey_typeText(searchString)]; | 330 performAction:grey_typeText(searchString)]; |
| 326 [[EarlGrey selectElementWithMatcher:HistoryEntry(_URL1, kTitle1)] | 331 [[EarlGrey selectElementWithMatcher:HistoryEntry(_URL1, kTitle1)] |
| 327 assertWithMatcher:grey_notNil()]; | 332 assertWithMatcher:grey_notNil()]; |
| 328 [[EarlGrey selectElementWithMatcher:HistoryEntry(_URL2, kTitle2)] | 333 [[EarlGrey selectElementWithMatcher:HistoryEntry(_URL2, kTitle2)] |
| 329 assertWithMatcher:grey_nil()]; | 334 assertWithMatcher:grey_nil()]; |
| 330 [[EarlGrey selectElementWithMatcher:HistoryEntry(_URL3, _URL3.GetContent())] | 335 [[EarlGrey selectElementWithMatcher:HistoryEntry(_URL3, _URL3.GetContent())] |
| 331 assertWithMatcher:grey_nil()]; | 336 assertWithMatcher:grey_nil()]; |
| 332 } | 337 } |
| 333 | 338 |
| 334 // Tests deletion of history entries. | 339 // Tests deletion of history entries. |
| 335 - (void)testDeleteHistory { | 340 // TODO(crbug.com/704403): Re-enable this test. |
| 341 - (void)DISABLED_testDeleteHistory { |
| 336 [self loadTestURLs]; | 342 [self loadTestURLs]; |
| 337 [self openHistoryPanel]; | 343 [self openHistoryPanel]; |
| 338 | 344 |
| 339 // Assert that three history elements are present. | 345 // Assert that three history elements are present. |
| 340 [[EarlGrey selectElementWithMatcher:HistoryEntry(_URL1, kTitle1)] | 346 [[EarlGrey selectElementWithMatcher:HistoryEntry(_URL1, kTitle1)] |
| 341 assertWithMatcher:grey_notNil()]; | 347 assertWithMatcher:grey_notNil()]; |
| 342 [[EarlGrey selectElementWithMatcher:HistoryEntry(_URL2, kTitle2)] | 348 [[EarlGrey selectElementWithMatcher:HistoryEntry(_URL2, kTitle2)] |
| 343 assertWithMatcher:grey_notNil()]; | 349 assertWithMatcher:grey_notNil()]; |
| 344 [[EarlGrey selectElementWithMatcher:HistoryEntry(_URL3, _URL3.GetContent())] | 350 [[EarlGrey selectElementWithMatcher:HistoryEntry(_URL3, _URL3.GetContent())] |
| 345 assertWithMatcher:grey_notNil()]; | 351 assertWithMatcher:grey_notNil()]; |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 529 - (void)resetBrowsingDataPrefs { | 535 - (void)resetBrowsingDataPrefs { |
| 530 PrefService* prefs = chrome_test_util::GetOriginalBrowserState()->GetPrefs(); | 536 PrefService* prefs = chrome_test_util::GetOriginalBrowserState()->GetPrefs(); |
| 531 prefs->ClearPref(browsing_data::prefs::kDeleteBrowsingHistory); | 537 prefs->ClearPref(browsing_data::prefs::kDeleteBrowsingHistory); |
| 532 prefs->ClearPref(browsing_data::prefs::kDeleteCookies); | 538 prefs->ClearPref(browsing_data::prefs::kDeleteCookies); |
| 533 prefs->ClearPref(browsing_data::prefs::kDeleteCache); | 539 prefs->ClearPref(browsing_data::prefs::kDeleteCache); |
| 534 prefs->ClearPref(browsing_data::prefs::kDeletePasswords); | 540 prefs->ClearPref(browsing_data::prefs::kDeletePasswords); |
| 535 prefs->ClearPref(browsing_data::prefs::kDeleteFormData); | 541 prefs->ClearPref(browsing_data::prefs::kDeleteFormData); |
| 536 } | 542 } |
| 537 | 543 |
| 538 @end | 544 @end |
| OLD | NEW |