| 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 <XCTest/XCTest.h> | 6 #import <XCTest/XCTest.h> |
| 7 | 7 |
| 8 #include "base/mac/bind_objc_block.h" | 8 #include "base/mac/bind_objc_block.h" |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 performAction:grey_tap()]; | 191 performAction:grey_tap()]; |
| 192 } | 192 } |
| 193 ConditionBlock condition = ^bool { | 193 ConditionBlock condition = ^bool { |
| 194 return !chrome_test_util::IsIncognitoMode(); | 194 return !chrome_test_util::IsIncognitoMode(); |
| 195 }; | 195 }; |
| 196 GREYAssert( | 196 GREYAssert( |
| 197 testing::WaitUntilConditionOrTimeout(kWaitElementTimeout, condition), | 197 testing::WaitUntilConditionOrTimeout(kWaitElementTimeout, condition), |
| 198 @"Waiting switch to normal mode."); | 198 @"Waiting switch to normal mode."); |
| 199 } | 199 } |
| 200 | 200 |
| 201 // Check that the error page is visible. | |
| 202 void CheckErrorPageIsVisible() { | |
| 203 // The DNS error page is static HTML content. | |
| 204 NSString* const kError = | |
| 205 l10n_util::GetNSString(IDS_ERRORPAGES_HEADING_NOT_AVAILABLE); | |
| 206 [[EarlGrey | |
| 207 selectElementWithMatcher:chrome_test_util::StaticHtmlViewContainingText( | |
| 208 kError)] assertWithMatcher:grey_notNil()]; | |
| 209 } | |
| 210 | |
| 211 // Open the settings submenu. Assumes that settings menu is visible. | 201 // Open the settings submenu. Assumes that settings menu is visible. |
| 212 void OpenSettingsSubMenuUnsynced(int submenu) { | 202 void OpenSettingsSubMenuUnsynced(int submenu) { |
| 213 id<GREYMatcher> settings_button_matcher = | 203 id<GREYMatcher> settings_button_matcher = |
| 214 grey_text(l10n_util::GetNSString(submenu)); | 204 grey_text(l10n_util::GetNSString(submenu)); |
| 215 [[[EarlGrey selectElementWithMatcher:settings_button_matcher] | 205 [[[EarlGrey selectElementWithMatcher:settings_button_matcher] |
| 216 usingSearchAction:grey_swipeSlowInDirection(kGREYDirectionUp) | 206 usingSearchAction:grey_swipeSlowInDirection(kGREYDirectionUp) |
| 217 onElementWithMatcher:grey_accessibilityID(kSettingsCollectionViewId)] | 207 onElementWithMatcher:grey_accessibilityID(kSettingsCollectionViewId)] |
| 218 performAction:grey_tap()]; | 208 performAction:grey_tap()]; |
| 219 } | 209 } |
| 220 | 210 |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 508 chrome_test_util::HistogramTester histogramTester; | 498 chrome_test_util::HistogramTester histogramTester; |
| 509 FailureBlock failureBlock = ^(NSString* error) { | 499 FailureBlock failureBlock = ^(NSString* error) { |
| 510 GREYFail(error); | 500 GREYFail(error); |
| 511 }; | 501 }; |
| 512 | 502 |
| 513 // This URL is purposely invalid so it triggers a navigation error. | 503 // This URL is purposely invalid so it triggers a navigation error. |
| 514 GURL invalidURL(kTestUrl1); | 504 GURL invalidURL(kTestUrl1); |
| 515 | 505 |
| 516 chrome_test_util::OpenNewTab(); | 506 chrome_test_util::OpenNewTab(); |
| 517 [ChromeEarlGrey loadURL:invalidURL]; | 507 [ChromeEarlGrey loadURL:invalidURL]; |
| 518 CheckErrorPageIsVisible(); | 508 [ChromeEarlGrey waitForErrorPage]; |
| 519 OpenNewIncognitoTabUsingUIAndEvictMainTabs(); | 509 OpenNewIncognitoTabUsingUIAndEvictMainTabs(); |
| 520 | 510 |
| 521 SwitchToNormalMode(); | 511 SwitchToNormalMode(); |
| 522 CheckErrorPageIsVisible(); | 512 [ChromeEarlGrey waitForErrorPage]; |
| 523 | 513 |
| 524 histogramTester.ExpectUniqueSample(kEvictedTabReloadSuccessRate, | 514 histogramTester.ExpectUniqueSample(kEvictedTabReloadSuccessRate, |
| 525 TabUsageRecorder::LOAD_FAILURE, 1, | 515 TabUsageRecorder::LOAD_FAILURE, 1, |
| 526 failureBlock); | 516 failureBlock); |
| 527 histogramTester.ExpectUniqueSample(kDidUserWaitForEvictedTabReload, | 517 histogramTester.ExpectUniqueSample(kDidUserWaitForEvictedTabReload, |
| 528 TabUsageRecorder::USER_WAITED, 1, | 518 TabUsageRecorder::USER_WAITED, 1, |
| 529 failureBlock); | 519 failureBlock); |
| 530 histogramTester.ExpectTotalCount(kEvictedTabReloadTime, 0, failureBlock); | 520 histogramTester.ExpectTotalCount(kEvictedTabReloadTime, 0, failureBlock); |
| 531 } | 521 } |
| 532 | 522 |
| (...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 938 [[GREYUIThreadExecutor sharedInstance] drainUntilIdle]; | 928 [[GREYUIThreadExecutor sharedInstance] drainUntilIdle]; |
| 939 } | 929 } |
| 940 // The deleted tabs are purged during foregrounding and backgrounding. | 930 // The deleted tabs are purged during foregrounding and backgrounding. |
| 941 chrome_test_util::SimulateTabsBackgrounding(); | 931 chrome_test_util::SimulateTabsBackgrounding(); |
| 942 // Make sure |evicted_tabs_| purged the deleted tabs. | 932 // Make sure |evicted_tabs_| purged the deleted tabs. |
| 943 int evicted = chrome_test_util::GetEvictedMainTabCount(); | 933 int evicted = chrome_test_util::GetEvictedMainTabCount(); |
| 944 GREYAssertEqual(evicted, 0, @"Check number of evicted tabs"); | 934 GREYAssertEqual(evicted, 0, @"Check number of evicted tabs"); |
| 945 } | 935 } |
| 946 | 936 |
| 947 @end | 937 @end |
| OLD | NEW |