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

Side by Side Diff: ios/chrome/browser/ui/tools_menu/tools_popup_menu_egtest.mm

Issue 2642193012: Make EarlGrey matchers compliant with Chromium style. (Closed)
Patch Set: build.gn and rebase Created 3 years, 11 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 <XCTest/XCTest.h> 6 #import <XCTest/XCTest.h>
7 7
8 #include "base/strings/sys_string_conversions.h" 8 #include "base/strings/sys_string_conversions.h"
9 #include "components/strings/grit/components_strings.h" 9 #include "components/strings/grit/components_strings.h"
10 #import "ios/chrome/browser/ui/chrome_web_view_factory.h" 10 #import "ios/chrome/browser/ui/chrome_web_view_factory.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 userAgent == kDesktopUserAgent) { 50 userAgent == kDesktopUserAgent) {
51 response_body->assign("Desktop"); 51 response_body->assign("Desktop");
52 } else { 52 } else {
53 response_body->assign("Mobile"); 53 response_body->assign("Mobile");
54 } 54 }
55 } 55 }
56 }; 56 };
57 57
58 // Matcher for the button to find in page. 58 // Matcher for the button to find in page.
59 id<GREYMatcher> FindInPageButton() { 59 id<GREYMatcher> FindInPageButton() {
60 return chrome_test_util::buttonWithAccessibilityLabel( 60 return chrome_test_util::ButtonWithAccessibilityLabel(
61 l10n_util::GetNSStringWithFixup(IDS_IOS_TOOLS_MENU_FIND_IN_PAGE)); 61 l10n_util::GetNSStringWithFixup(IDS_IOS_TOOLS_MENU_FIND_IN_PAGE));
62 } 62 }
63 63
64 // Matcher for the button to request desktop version. 64 // Matcher for the button to request desktop version.
65 id<GREYMatcher> RequestDesktopButton() { 65 id<GREYMatcher> RequestDesktopButton() {
66 return grey_accessibilityID(kToolsMenuRequestDesktopId); 66 return grey_accessibilityID(kToolsMenuRequestDesktopId);
67 } 67 }
68 68
69 // Matcher for the navigate backward button.
70 id<GREYMatcher> BackButton() {
71 return chrome_test_util::buttonWithAccessibilityLabelId(IDS_ACCNAME_BACK);
72 }
73
74 const char kPDFURL[] = "http://ios/testing/data/http_server_files/testpage.pdf"; 69 const char kPDFURL[] = "http://ios/testing/data/http_server_files/testpage.pdf";
75 70
76 } // namespace 71 } // namespace
77 72
78 // Tests for the tools popup menu. 73 // Tests for the tools popup menu.
79 @interface ToolsPopupMenuTestCase : ChromeTestCase 74 @interface ToolsPopupMenuTestCase : ChromeTestCase
80 - (void)verifyMobileAndDesktopVersions:(const GURL&)url; 75 - (void)verifyMobileAndDesktopVersions:(const GURL&)url;
81 @end 76 @end
82 77
83 @implementation ToolsPopupMenuTestCase 78 @implementation ToolsPopupMenuTestCase
84 79
85 // Verify that requesting desktop and mobile versions works. 80 // Verify that requesting desktop and mobile versions works.
86 - (void)verifyMobileAndDesktopVersions:(const GURL&)url { 81 - (void)verifyMobileAndDesktopVersions:(const GURL&)url {
87 NSString* const kMobileSiteLabel = @"Mobile"; 82 NSString* const kMobileSiteLabel = @"Mobile";
88 NSString* const kDesktopSiteLabel = @"Desktop"; 83 NSString* const kDesktopSiteLabel = @"Desktop";
89 84
90 [ChromeEarlGrey loadURL:url]; 85 [ChromeEarlGrey loadURL:url];
91 86
92 // Verify initial reception of the mobile site. 87 // Verify initial reception of the mobile site.
93 [[EarlGrey 88 [[EarlGrey
94 selectElementWithMatcher:chrome_test_util::webViewContainingText( 89 selectElementWithMatcher:chrome_test_util::WebViewContainingText(
95 base::SysNSStringToUTF8(kMobileSiteLabel))] 90 base::SysNSStringToUTF8(kMobileSiteLabel))]
96 assertWithMatcher:grey_notNil()]; 91 assertWithMatcher:grey_notNil()];
97 92
98 // Request and verify reception of the desktop site. 93 // Request and verify reception of the desktop site.
99 [ChromeEarlGreyUI openToolsMenu]; 94 [ChromeEarlGreyUI openToolsMenu];
100 [[EarlGrey selectElementWithMatcher:RequestDesktopButton()] 95 [[EarlGrey selectElementWithMatcher:RequestDesktopButton()]
101 performAction:grey_tap()]; 96 performAction:grey_tap()];
102 [[EarlGrey 97 [[EarlGrey
103 selectElementWithMatcher:chrome_test_util::webViewContainingText( 98 selectElementWithMatcher:chrome_test_util::WebViewContainingText(
104 base::SysNSStringToUTF8(kDesktopSiteLabel))] 99 base::SysNSStringToUTF8(kDesktopSiteLabel))]
105 assertWithMatcher:grey_notNil()]; 100 assertWithMatcher:grey_notNil()];
106 101
107 // Verify that going back returns to the mobile site. 102 // Verify that going back returns to the mobile site.
108 [[EarlGrey selectElementWithMatcher:BackButton()] performAction:grey_tap()]; 103 [[EarlGrey selectElementWithMatcher:chrome_test_util::BackButton()]
104 performAction:grey_tap()];
109 [[EarlGrey 105 [[EarlGrey
110 selectElementWithMatcher:chrome_test_util::webViewContainingText( 106 selectElementWithMatcher:chrome_test_util::WebViewContainingText(
111 base::SysNSStringToUTF8(kMobileSiteLabel))] 107 base::SysNSStringToUTF8(kMobileSiteLabel))]
112 assertWithMatcher:grey_notNil()]; 108 assertWithMatcher:grey_notNil()];
113 } 109 }
114 110
115 // Tests that the menu is closed when tapping the close button. 111 // Tests that the menu is closed when tapping the close button.
116 - (void)testOpenAndCloseToolsMenu { 112 - (void)testOpenAndCloseToolsMenu {
117 [ChromeEarlGreyUI openToolsMenu]; 113 [ChromeEarlGreyUI openToolsMenu];
118 114
119 if (!IsCompact()) { 115 if (!IsCompact()) {
120 [[EarlGrey 116 [[EarlGrey
121 selectElementWithMatcher:grey_accessibilityLabel(l10n_util::GetNSString( 117 selectElementWithMatcher:grey_accessibilityLabel(l10n_util::GetNSString(
122 IDS_IOS_TOOLBAR_CLOSE_MENU))] 118 IDS_IOS_TOOLBAR_CLOSE_MENU))]
123 performAction:grey_tap()]; 119 performAction:grey_tap()];
124 } else { 120 } else {
125 [[EarlGrey selectElementWithMatcher:chrome_test_util::toolsMenuButton()] 121 [[EarlGrey selectElementWithMatcher:chrome_test_util::ToolsMenuButton()]
126 performAction:grey_tap()]; 122 performAction:grey_tap()];
127 } 123 }
128 124
129 [[EarlGrey 125 [[EarlGrey
130 selectElementWithMatcher:grey_accessibilityID(kToolsMenuTableViewId)] 126 selectElementWithMatcher:grey_accessibilityID(kToolsMenuTableViewId)]
131 assertWithMatcher:grey_notVisible()]; 127 assertWithMatcher:grey_notVisible()];
132 } 128 }
133 129
134 // Navigates to a pdf page and verifies that the "Find in Page..." tool 130 // Navigates to a pdf page and verifies that the "Find in Page..." tool
135 // is not enabled 131 // is not enabled
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 165
170 // Open tools menu and verify elements are accessible. 166 // Open tools menu and verify elements are accessible.
171 - (void)testAccessibilityOnToolsMenu { 167 - (void)testAccessibilityOnToolsMenu {
172 [ChromeEarlGreyUI openToolsMenu]; 168 [ChromeEarlGreyUI openToolsMenu];
173 chrome_test_util::VerifyAccessibilityForCurrentScreen(); 169 chrome_test_util::VerifyAccessibilityForCurrentScreen();
174 // Close Tools menu. 170 // Close Tools menu.
175 [ChromeTestCase removeAnyOpenMenusAndInfoBars]; 171 [ChromeTestCase removeAnyOpenMenusAndInfoBars];
176 } 172 }
177 173
178 @end 174 @end
OLDNEW
« no previous file with comments | « ios/chrome/browser/ui/toolbar/toolbar_egtest.mm ('k') | ios/chrome/browser/ui/webui/web_ui_egtest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698