| 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/content_settings/core/browser/host_content_settings_map.h" | 10 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 [ChromeEarlGrey loadURL:testURL]; | 90 [ChromeEarlGrey loadURL:testURL]; |
| 91 chrome_test_util::AssertMainTabCount(1U); | 91 chrome_test_util::AssertMainTabCount(1U); |
| 92 | 92 |
| 93 // Tap on the test link and wait for the page to display "Click done", as an | 93 // Tap on the test link and wait for the page to display "Click done", as an |
| 94 // indicator that the element was tapped. | 94 // indicator that the element was tapped. |
| 95 chrome_test_util::TapWebViewElementWithId(linkID); | 95 chrome_test_util::TapWebViewElementWithId(linkID); |
| 96 [[GREYCondition | 96 [[GREYCondition |
| 97 conditionWithName:@"Waiting for webview to display 'Click done'." | 97 conditionWithName:@"Waiting for webview to display 'Click done'." |
| 98 block:^BOOL { | 98 block:^BOOL { |
| 99 id<GREYMatcher> webViewMatcher = | 99 id<GREYMatcher> webViewMatcher = |
| 100 chrome_test_util::webViewContainingText("Click done"); | 100 chrome_test_util::WebViewContainingText("Click done"); |
| 101 NSError* error = nil; | 101 NSError* error = nil; |
| 102 [[EarlGrey selectElementWithMatcher:webViewMatcher] | 102 [[EarlGrey selectElementWithMatcher:webViewMatcher] |
| 103 assertWithMatcher:grey_notNil() | 103 assertWithMatcher:grey_notNil() |
| 104 error:&error]; | 104 error:&error]; |
| 105 return error == nil; | 105 return error == nil; |
| 106 }] waitWithTimeout:kConditionTimeout]; | 106 }] waitWithTimeout:kConditionTimeout]; |
| 107 | 107 |
| 108 // Check that no navigation occurred and no new tabs were opened. | 108 // Check that no navigation occurred and no new tabs were opened. |
| 109 chrome_test_util::AssertMainTabCount(1U); | 109 chrome_test_util::AssertMainTabCount(1U); |
| 110 const GURL& currentURL = | 110 const GURL& currentURL = |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 // Tap on the test link. | 145 // Tap on the test link. |
| 146 const std::string linkID = | 146 const std::string linkID = |
| 147 "webScenarioBrowsingLinkPreventDefaultOverridesWindowOpen"; | 147 "webScenarioBrowsingLinkPreventDefaultOverridesWindowOpen"; |
| 148 chrome_test_util::TapWebViewElementWithId(linkID); | 148 chrome_test_util::TapWebViewElementWithId(linkID); |
| 149 | 149 |
| 150 // Stall a bit to make sure the webview doesn't do anything asynchronously. | 150 // Stall a bit to make sure the webview doesn't do anything asynchronously. |
| 151 [[GREYCondition | 151 [[GREYCondition |
| 152 conditionWithName:@"Waiting for webview to display 'Click done'." | 152 conditionWithName:@"Waiting for webview to display 'Click done'." |
| 153 block:^BOOL { | 153 block:^BOOL { |
| 154 id<GREYMatcher> webViewMatcher = | 154 id<GREYMatcher> webViewMatcher = |
| 155 chrome_test_util::webViewContainingText("Click done"); | 155 chrome_test_util::WebViewContainingText("Click done"); |
| 156 NSError* error = nil; | 156 NSError* error = nil; |
| 157 [[EarlGrey selectElementWithMatcher:webViewMatcher] | 157 [[EarlGrey selectElementWithMatcher:webViewMatcher] |
| 158 assertWithMatcher:grey_notNil() | 158 assertWithMatcher:grey_notNil() |
| 159 error:&error]; | 159 error:&error]; |
| 160 return error == nil; | 160 return error == nil; |
| 161 }] waitWithTimeout:kConditionTimeout]; | 161 }] waitWithTimeout:kConditionTimeout]; |
| 162 | 162 |
| 163 // Check that the tab navigated to about:blank and no new tabs were opened. | 163 // Check that the tab navigated to about:blank and no new tabs were opened. |
| 164 [[GREYCondition | 164 [[GREYCondition |
| 165 conditionWithName:@"Wait for navigation to about:blank" | 165 conditionWithName:@"Wait for navigation to about:blank" |
| 166 block:^BOOL { | 166 block:^BOOL { |
| 167 const GURL& currentURL = | 167 const GURL& currentURL = |
| 168 chrome_test_util::GetCurrentWebState()->GetVisibleURL(); | 168 chrome_test_util::GetCurrentWebState()->GetVisibleURL(); |
| 169 return currentURL == GURL(url::kAboutBlankURL); | 169 return currentURL == GURL(url::kAboutBlankURL); |
| 170 }] waitWithTimeout:kConditionTimeout]; | 170 }] waitWithTimeout:kConditionTimeout]; |
| 171 chrome_test_util::AssertMainTabCount(1U); | 171 chrome_test_util::AssertMainTabCount(1U); |
| 172 } | 172 } |
| 173 | 173 |
| 174 @end | 174 @end |
| OLD | NEW |