| 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 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 ConditionBlock condition = ^bool { | 197 ConditionBlock condition = ^bool { |
| 198 return !chrome_test_util::IsIncognitoMode(); | 198 return !chrome_test_util::IsIncognitoMode(); |
| 199 }; | 199 }; |
| 200 GREYAssert( | 200 GREYAssert( |
| 201 testing::WaitUntilConditionOrTimeout(kWaitElementTimeout, condition), | 201 testing::WaitUntilConditionOrTimeout(kWaitElementTimeout, condition), |
| 202 @"Waiting switch to normal mode."); | 202 @"Waiting switch to normal mode."); |
| 203 } | 203 } |
| 204 | 204 |
| 205 // Check that the error page is visible. | 205 // Check that the error page is visible. |
| 206 void CheckErrorPageIsVisible() { | 206 void CheckErrorPageIsVisible() { |
| 207 // The DNS error page is static HTML content, so it isn't part of the webview | 207 // The DNS error page is static HTML content. |
| 208 // owned by the webstate. | |
| 209 id<GREYMatcher> webViewMatcher = | |
| 210 web::WebViewInWebState(chrome_test_util::GetCurrentWebState()); | |
| 211 [[EarlGrey selectElementWithMatcher:webViewMatcher] | |
| 212 assertWithMatcher:grey_nil()]; | |
| 213 NSString* const kError = | 208 NSString* const kError = |
| 214 l10n_util::GetNSString(IDS_ERRORPAGES_HEADING_NOT_AVAILABLE); | 209 l10n_util::GetNSString(IDS_ERRORPAGES_HEADING_NOT_AVAILABLE); |
| 215 [[EarlGrey | 210 [[EarlGrey |
| 216 selectElementWithMatcher:chrome_test_util::StaticHtmlViewContainingText( | 211 selectElementWithMatcher:chrome_test_util::StaticHtmlViewContainingText( |
| 217 kError)] assertWithMatcher:grey_notNil()]; | 212 kError)] assertWithMatcher:grey_notNil()]; |
| 218 } | 213 } |
| 219 | 214 |
| 220 // Open the settings submenu. Assumes that settings menu is visible. | 215 // Open the settings submenu. Assumes that settings menu is visible. |
| 221 void OpenSettingsSubMenuUnsynced(int submenu) { | 216 void OpenSettingsSubMenuUnsynced(int submenu) { |
| 222 id<GREYMatcher> settings_button_matcher = | 217 id<GREYMatcher> settings_button_matcher = |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 508 TabUsageRecorder::LOAD_SUCCESS, 1, | 503 TabUsageRecorder::LOAD_SUCCESS, 1, |
| 509 failureBlock); | 504 failureBlock); |
| 510 histogramTester.ExpectUniqueSample(kDidUserWaitForEvictedTabReload, | 505 histogramTester.ExpectUniqueSample(kDidUserWaitForEvictedTabReload, |
| 511 TabUsageRecorder::USER_WAITED, 1, | 506 TabUsageRecorder::USER_WAITED, 1, |
| 512 failureBlock); | 507 failureBlock); |
| 513 histogramTester.ExpectTotalCount(kEvictedTabReloadTime, 1, failureBlock); | 508 histogramTester.ExpectTotalCount(kEvictedTabReloadTime, 1, failureBlock); |
| 514 } | 509 } |
| 515 | 510 |
| 516 // Verify correct recording of metrics when the reloading of an evicted tab | 511 // Verify correct recording of metrics when the reloading of an evicted tab |
| 517 // fails. | 512 // fails. |
| 518 // TODO(crbug.com/684987): Re-enable this test. | 513 - (void)testEvictedTabReloadFailure { |
| 519 - (void)DISABLED_testEvictedTabReloadFailure { | |
| 520 web::test::SetUpFileBasedHttpServer(); | 514 web::test::SetUpFileBasedHttpServer(); |
| 521 chrome_test_util::HistogramTester histogramTester; | 515 chrome_test_util::HistogramTester histogramTester; |
| 522 FailureBlock failureBlock = ^(NSString* error) { | 516 FailureBlock failureBlock = ^(NSString* error) { |
| 523 GREYFail(error); | 517 GREYFail(error); |
| 524 }; | 518 }; |
| 525 | 519 |
| 526 // This URL is purposely invalid so it triggers a navigation error. | 520 // This URL is purposely invalid so it triggers a navigation error. |
| 527 GURL invalidURL(kTestUrl1); | 521 GURL invalidURL(kTestUrl1); |
| 528 | 522 |
| 529 chrome_test_util::OpenNewTab(); | 523 chrome_test_util::OpenNewTab(); |
| (...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 959 [[GREYUIThreadExecutor sharedInstance] drainUntilIdle]; | 953 [[GREYUIThreadExecutor sharedInstance] drainUntilIdle]; |
| 960 } | 954 } |
| 961 // The deleted tabs are purged during foregrounding and backgrounding. | 955 // The deleted tabs are purged during foregrounding and backgrounding. |
| 962 chrome_test_util::SimulateTabsBackgrounding(); | 956 chrome_test_util::SimulateTabsBackgrounding(); |
| 963 // Make sure |evicted_tabs_| purged the deleted tabs. | 957 // Make sure |evicted_tabs_| purged the deleted tabs. |
| 964 int evicted = chrome_test_util::GetEvictedMainTabCount(); | 958 int evicted = chrome_test_util::GetEvictedMainTabCount(); |
| 965 GREYAssertEqual(evicted, 0, @"Check number of evicted tabs"); | 959 GREYAssertEqual(evicted, 0, @"Check number of evicted tabs"); |
| 966 } | 960 } |
| 967 | 961 |
| 968 @end | 962 @end |
| OLD | NEW |