Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(225)

Side by Side Diff: ios/chrome/browser/ui/settings/block_popups_egtest.mm

Issue 2733973002: Create shared matcher for navigation bar done button. (Closed)
Patch Set: remove sufficientlyVisible from shared matcher Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/ios/ios_util.h" 9 #include "base/ios/ios_util.h"
10 #include "base/strings/sys_string_conversions.h" 10 #include "base/strings/sys_string_conversions.h"
(...skipping 13 matching lines...) Expand all
24 #import "ios/chrome/test/earl_grey/chrome_earl_grey.h" 24 #import "ios/chrome/test/earl_grey/chrome_earl_grey.h"
25 #import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h" 25 #import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h"
26 #import "ios/chrome/test/earl_grey/chrome_matchers.h" 26 #import "ios/chrome/test/earl_grey/chrome_matchers.h"
27 #import "ios/chrome/test/earl_grey/chrome_test_case.h" 27 #import "ios/chrome/test/earl_grey/chrome_test_case.h"
28 #import "ios/web/public/test/http_server.h" 28 #import "ios/web/public/test/http_server.h"
29 #include "ios/web/public/test/http_server_util.h" 29 #include "ios/web/public/test/http_server_util.h"
30 #import "ios/web/public/test/web_view_interaction_test_util.h" 30 #import "ios/web/public/test/web_view_interaction_test_util.h"
31 #include "ui/base/l10n/l10n_util_mac.h" 31 #include "ui/base/l10n/l10n_util_mac.h"
32 #include "url/gurl.h" 32 #include "url/gurl.h"
33 33
34 using chrome_test_util::NavigationBarDoneButton;
35
34 namespace { 36 namespace {
35 37
36 // URLs used in the tests. 38 // URLs used in the tests.
37 const char* kBlockPopupsUrl = "http://blockpopups"; 39 const char* kBlockPopupsUrl = "http://blockpopups";
38 const char* kOpenedWindowUrl = "http://openedwindow"; 40 const char* kOpenedWindowUrl = "http://openedwindow";
39 41
40 // JavaScript to open a new window after a short delay. 42 // JavaScript to open a new window after a short delay.
41 NSString* kBlockPopupsResponseTemplate = 43 NSString* kBlockPopupsResponseTemplate =
42 @"<input type=\"button\" onclick=\"setTimeout(function() {" 44 @"<input type=\"button\" onclick=\"setTimeout(function() {"
43 "window.open('%@')}, 1)\" " 45 "window.open('%@')}, 1)\" "
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 grey_accessibilityID(@"ic_arrow_back"), 86 grey_accessibilityID(@"ic_arrow_back"),
85 grey_accessibilityTrait( 87 grey_accessibilityTrait(
86 UIAccessibilityTraitButton), 88 UIAccessibilityTraitButton),
87 nil)] performAction:grey_tap()]; 89 nil)] performAction:grey_tap()];
88 [[EarlGrey 90 [[EarlGrey
89 selectElementWithMatcher:grey_allOf( 91 selectElementWithMatcher:grey_allOf(
90 grey_accessibilityID(@"ic_arrow_back"), 92 grey_accessibilityID(@"ic_arrow_back"),
91 grey_accessibilityTrait( 93 grey_accessibilityTrait(
92 UIAccessibilityTraitButton), 94 UIAccessibilityTraitButton),
93 nil)] performAction:grey_tap()]; 95 nil)] performAction:grey_tap()];
94 [[EarlGrey 96 [[EarlGrey selectElementWithMatcher:NavigationBarDoneButton()]
95 selectElementWithMatcher:chrome_test_util::ButtonWithAccessibilityLabelId(
96 IDS_IOS_NAVIGATION_BAR_DONE_BUTTON)]
97 performAction:grey_tap()]; 97 performAction:grey_tap()];
98 } 98 }
99 99
100 // ScopedBlockPopupsPref modifies the block popups preference and resets the 100 // ScopedBlockPopupsPref modifies the block popups preference and resets the
101 // preference to its original value when this object goes out of scope. 101 // preference to its original value when this object goes out of scope.
102 class ScopedBlockPopupsPref { 102 class ScopedBlockPopupsPref {
103 public: 103 public:
104 ScopedBlockPopupsPref(ContentSetting setting) { 104 ScopedBlockPopupsPref(ContentSetting setting) {
105 original_setting_ = GetPrefValue(); 105 original_setting_ = GetPrefValue();
106 SetPrefValue(setting); 106 SetPrefValue(setting);
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 selectElementWithMatcher:chrome_test_util::CollectionViewSwitchCell( 268 selectElementWithMatcher:chrome_test_util::CollectionViewSwitchCell(
269 @"blockPopupsContentView_switch", YES)] 269 @"blockPopupsContentView_switch", YES)]
270 performAction:chrome_test_util::turnCollectionViewSwitchOn(NO)]; 270 performAction:chrome_test_util::turnCollectionViewSwitchOn(NO)];
271 [[EarlGrey selectElementWithMatcher:grey_text(base::SysUTF8ToNSString( 271 [[EarlGrey selectElementWithMatcher:grey_text(base::SysUTF8ToNSString(
272 allowedPattern))] 272 allowedPattern))]
273 assertWithMatcher:grey_notVisible()]; 273 assertWithMatcher:grey_notVisible()];
274 [[EarlGrey 274 [[EarlGrey
275 selectElementWithMatcher:grey_accessibilityLabel(l10n_util::GetNSString( 275 selectElementWithMatcher:grey_accessibilityLabel(l10n_util::GetNSString(
276 IDS_IOS_NAVIGATION_BAR_EDIT_BUTTON))] 276 IDS_IOS_NAVIGATION_BAR_EDIT_BUTTON))]
277 assertWithMatcher:grey_notVisible()]; 277 assertWithMatcher:grey_notVisible()];
278 [[EarlGrey 278 [[EarlGrey selectElementWithMatcher:NavigationBarDoneButton()]
279 selectElementWithMatcher:grey_accessibilityLabel(l10n_util::GetNSString(
280 IDS_IOS_NAVIGATION_BAR_DONE_BUTTON))]
281 assertWithMatcher:grey_sufficientlyVisible()]; 279 assertWithMatcher:grey_sufficientlyVisible()];
282 280
283 // Toggle the switch back on via the UI and make sure the exceptions are now 281 // Toggle the switch back on via the UI and make sure the exceptions are now
284 // visible. 282 // visible.
285 [[EarlGrey 283 [[EarlGrey
286 selectElementWithMatcher:chrome_test_util::CollectionViewSwitchCell( 284 selectElementWithMatcher:chrome_test_util::CollectionViewSwitchCell(
287 @"blockPopupsContentView_switch", NO)] 285 @"blockPopupsContentView_switch", NO)]
288 performAction:chrome_test_util::turnCollectionViewSwitchOn(YES)]; 286 performAction:chrome_test_util::turnCollectionViewSwitchOn(YES)];
289 [[EarlGrey selectElementWithMatcher:grey_text(base::SysUTF8ToNSString( 287 [[EarlGrey selectElementWithMatcher:grey_text(base::SysUTF8ToNSString(
290 allowedPattern))] 288 allowedPattern))]
291 assertWithMatcher:grey_sufficientlyVisible()]; 289 assertWithMatcher:grey_sufficientlyVisible()];
292 [[EarlGrey 290 [[EarlGrey
293 selectElementWithMatcher:grey_accessibilityLabel(l10n_util::GetNSString( 291 selectElementWithMatcher:grey_accessibilityLabel(l10n_util::GetNSString(
294 IDS_IOS_NAVIGATION_BAR_EDIT_BUTTON))] 292 IDS_IOS_NAVIGATION_BAR_EDIT_BUTTON))]
295 assertWithMatcher:grey_sufficientlyVisible()]; 293 assertWithMatcher:grey_sufficientlyVisible()];
296 294
297 CloseSettings(); 295 CloseSettings();
298 } 296 }
299 297
300 @end 298 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698