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

Side by Side Diff: ios/web/shell/test/context_menu_egtest.mm

Issue 2642193012: Make EarlGrey matchers compliant with Chromium style. (Closed)
Patch Set: build.gn and rebase Created 3 years, 10 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 <WebKit/WebKit.h> 7 #import <WebKit/WebKit.h>
8 #import <XCTest/XCTest.h> 8 #import <XCTest/XCTest.h>
9 9
10 #import "base/ios/block_types.h" 10 #import "base/ios/block_types.h"
11 #include "base/strings/sys_string_conversions.h" 11 #include "base/strings/sys_string_conversions.h"
12 #import "ios/testing/earl_grey/matchers.h" 12 #import "ios/testing/earl_grey/matchers.h"
13 #import "ios/web/public/test/http_server.h" 13 #import "ios/web/public/test/http_server.h"
14 #include "ios/web/public/test/http_server_util.h" 14 #include "ios/web/public/test/http_server_util.h"
15 #import "ios/web/public/test/web_view_interaction_test_util.h" 15 #import "ios/web/public/test/web_view_interaction_test_util.h"
16 #import "ios/web/shell/test/app/web_shell_test_util.h" 16 #import "ios/web/shell/test/app/web_shell_test_util.h"
17 #include "ios/web/shell/test/app/web_view_interaction_test_util.h" 17 #include "ios/web/shell/test/app/web_view_interaction_test_util.h"
18 #import "ios/web/shell/test/earl_grey/shell_base_test_case.h" 18 #import "ios/web/shell/test/earl_grey/shell_base_test_case.h"
19 #import "ios/web/shell/test/earl_grey/shell_actions.h" 19 #import "ios/web/shell/test/earl_grey/shell_actions.h"
20 #import "ios/web/shell/test/earl_grey/shell_earl_grey.h" 20 #import "ios/web/shell/test/earl_grey/shell_earl_grey.h"
21 #import "ios/web/shell/test/earl_grey/shell_matchers.h" 21 #import "ios/web/shell/test/earl_grey/shell_matchers.h"
22 22
23 #if !defined(__has_feature) || !__has_feature(objc_arc) 23 #if !defined(__has_feature) || !__has_feature(objc_arc)
24 #error "This file requires ARC support." 24 #error "This file requires ARC support."
25 #endif 25 #endif
26 26
27 using testing::contextMenuItemWithText; 27 using testing::ContextMenuItemWithText;
28 using testing::elementToDismissContextMenu; 28 using testing::ElementToDismissContextMenu;
29 29
30 // Context menu test cases for the web shell. 30 // Context menu test cases for the web shell.
31 @interface ContextMenuTestCase : ShellBaseTestCase 31 @interface ContextMenuTestCase : ShellBaseTestCase
32 @end 32 @end
33 33
34 @implementation ContextMenuTestCase 34 @implementation ContextMenuTestCase
35 35
36 // TODO(crbug.com/675399): Re-enable this test on device. 36 // TODO(crbug.com/675399): Re-enable this test on device.
37 #if TARGET_IPHONE_SIMULATOR 37 #if TARGET_IPHONE_SIMULATOR
38 #define MAYBE_testContextMenu testContextMenu 38 #define MAYBE_testContextMenu testContextMenu
(...skipping 11 matching lines...) Expand all
50 responses[initialURL] = 50 responses[initialURL] =
51 "<body>" 51 "<body>"
52 "<a href='" + 52 "<a href='" +
53 destinationURL.spec() + "' id='" + linkID + 53 destinationURL.spec() + "' id='" + linkID +
54 "'>link for context menu</a>" 54 "'>link for context menu</a>"
55 "</span></body>"; 55 "</span></body>";
56 56
57 web::test::SetUpSimpleHttpServer(responses); 57 web::test::SetUpSimpleHttpServer(responses);
58 [ShellEarlGrey loadURL:initialURL]; 58 [ShellEarlGrey loadURL:initialURL];
59 59
60 [[EarlGrey selectElementWithMatcher:web::webView()] 60 [[EarlGrey selectElementWithMatcher:web::WebView()]
61 performAction:web::longPressElementForContextMenu( 61 performAction:web::longPressElementForContextMenu(
62 linkID, true /* menu should appear */)]; 62 linkID, true /* menu should appear */)];
63 63
64 id<GREYMatcher> copyItem = contextMenuItemWithText(@"Copy Link"); 64 id<GREYMatcher> copyItem = ContextMenuItemWithText(@"Copy Link");
65 65
66 // Context menu should have a "copy link" item. 66 // Context menu should have a "copy link" item.
67 [[EarlGrey selectElementWithMatcher:copyItem] 67 [[EarlGrey selectElementWithMatcher:copyItem]
68 assertWithMatcher:grey_notNil()]; 68 assertWithMatcher:grey_notNil()];
69 69
70 // Dismiss the context menu. 70 // Dismiss the context menu.
71 [[EarlGrey selectElementWithMatcher:elementToDismissContextMenu(@"Cancel")] 71 [[EarlGrey selectElementWithMatcher:ElementToDismissContextMenu(@"Cancel")]
72 performAction:grey_tap()]; 72 performAction:grey_tap()];
73 73
74 // Context menu should go away after the tap. 74 // Context menu should go away after the tap.
75 [[EarlGrey selectElementWithMatcher:copyItem] assertWithMatcher:grey_nil()]; 75 [[EarlGrey selectElementWithMatcher:copyItem] assertWithMatcher:grey_nil()];
76 } 76 }
77 77
78 // TODO(crbug.com/675399): Re-enable this test on device. 78 // TODO(crbug.com/675399): Re-enable this test on device.
79 #if TARGET_IPHONE_SIMULATOR 79 #if TARGET_IPHONE_SIMULATOR
80 #define MAYBE_testContextMenuWebkitTouchCalloutNone \ 80 #define MAYBE_testContextMenuWebkitTouchCalloutNone \
81 testContextMenuWebkitTouchCalloutNone 81 testContextMenuWebkitTouchCalloutNone
(...skipping 13 matching lines...) Expand all
95 std::string linkID = "link"; 95 std::string linkID = "link";
96 responses[initialURL] = "<body><a href='" + destinationURL.spec() + 96 responses[initialURL] = "<body><a href='" + destinationURL.spec() +
97 "' style='-webkit-touch-callout: none' id='" + 97 "' style='-webkit-touch-callout: none' id='" +
98 linkID + 98 linkID +
99 "'>no-callout link</a>" 99 "'>no-callout link</a>"
100 "</body>"; 100 "</body>";
101 101
102 web::test::SetUpSimpleHttpServer(responses); 102 web::test::SetUpSimpleHttpServer(responses);
103 [ShellEarlGrey loadURL:initialURL]; 103 [ShellEarlGrey loadURL:initialURL];
104 104
105 [[EarlGrey selectElementWithMatcher:web::webView()] 105 [[EarlGrey selectElementWithMatcher:web::WebView()]
106 performAction:web::longPressElementForContextMenu( 106 performAction:web::longPressElementForContextMenu(
107 linkID, false /* menu shouldn't appear */)]; 107 linkID, false /* menu shouldn't appear */)];
108 108
109 id<GREYMatcher> copyItem = contextMenuItemWithText(@"Copy Link"); 109 id<GREYMatcher> copyItem = ContextMenuItemWithText(@"Copy Link");
110 110
111 // Verify no context menu. 111 // Verify no context menu.
112 [[EarlGrey selectElementWithMatcher:copyItem] assertWithMatcher:grey_nil()]; 112 [[EarlGrey selectElementWithMatcher:copyItem] assertWithMatcher:grey_nil()];
113 } 113 }
114 114
115 // TODO(crbug.com/675399): Re-enable this test on device. 115 // TODO(crbug.com/675399): Re-enable this test on device.
116 #if TARGET_IPHONE_SIMULATOR 116 #if TARGET_IPHONE_SIMULATOR
117 #define MAYBE_testContextMenuWebkitTouchCalloutNoneFromAncestor \ 117 #define MAYBE_testContextMenuWebkitTouchCalloutNoneFromAncestor \
118 testContextMenuWebkitTouchCalloutNoneFromAncestor 118 testContextMenuWebkitTouchCalloutNoneFromAncestor
119 #else 119 #else
(...skipping 14 matching lines...) Expand all
134 responses[initialURL] = 134 responses[initialURL] =
135 "<body style='-webkit-touch-callout: none'>" 135 "<body style='-webkit-touch-callout: none'>"
136 "<a href='" + 136 "<a href='" +
137 destinationURL.spec() + "' id='" + linkID + 137 destinationURL.spec() + "' id='" + linkID +
138 "'>ancestor no-callout link</a>" 138 "'>ancestor no-callout link</a>"
139 "</body>"; 139 "</body>";
140 140
141 web::test::SetUpSimpleHttpServer(responses); 141 web::test::SetUpSimpleHttpServer(responses);
142 [ShellEarlGrey loadURL:initialURL]; 142 [ShellEarlGrey loadURL:initialURL];
143 143
144 [[EarlGrey selectElementWithMatcher:web::webView()] 144 [[EarlGrey selectElementWithMatcher:web::WebView()]
145 performAction:web::longPressElementForContextMenu( 145 performAction:web::longPressElementForContextMenu(
146 linkID, false /* menu shouldn't appear */)]; 146 linkID, false /* menu shouldn't appear */)];
147 147
148 id<GREYMatcher> copyItem = contextMenuItemWithText(@"Copy Link"); 148 id<GREYMatcher> copyItem = ContextMenuItemWithText(@"Copy Link");
149 149
150 // Verify no context menu. 150 // Verify no context menu.
151 [[EarlGrey selectElementWithMatcher:copyItem] assertWithMatcher:grey_nil()]; 151 [[EarlGrey selectElementWithMatcher:copyItem] assertWithMatcher:grey_nil()];
152 } 152 }
153 153
154 // TODO(crbug.com/675399): Re-enable this test on device. 154 // TODO(crbug.com/675399): Re-enable this test on device.
155 #if TARGET_IPHONE_SIMULATOR 155 #if TARGET_IPHONE_SIMULATOR
156 #define MAYBE_testContextMenuWebkitTouchCalloutOverride \ 156 #define MAYBE_testContextMenuWebkitTouchCalloutOverride \
157 testContextMenuWebkitTouchCalloutOverride 157 testContextMenuWebkitTouchCalloutOverride
158 #else 158 #else
(...skipping 15 matching lines...) Expand all
174 "<body style='-webkit-touch-callout: none'>" 174 "<body style='-webkit-touch-callout: none'>"
175 "<a href='" + 175 "<a href='" +
176 destinationURL.spec() + "' style='-webkit-touch-callout: default' id='" + 176 destinationURL.spec() + "' style='-webkit-touch-callout: default' id='" +
177 linkID + 177 linkID +
178 "'>override no-callout link</a>" 178 "'>override no-callout link</a>"
179 "</body>"; 179 "</body>";
180 180
181 web::test::SetUpSimpleHttpServer(responses); 181 web::test::SetUpSimpleHttpServer(responses);
182 [ShellEarlGrey loadURL:initialURL]; 182 [ShellEarlGrey loadURL:initialURL];
183 183
184 [[EarlGrey selectElementWithMatcher:web::webView()] 184 [[EarlGrey selectElementWithMatcher:web::WebView()]
185 performAction:web::longPressElementForContextMenu( 185 performAction:web::longPressElementForContextMenu(
186 linkID, true /* menu should appear */)]; 186 linkID, true /* menu should appear */)];
187 187
188 id<GREYMatcher> copyItem = contextMenuItemWithText(@"Copy Link"); 188 id<GREYMatcher> copyItem = ContextMenuItemWithText(@"Copy Link");
189 189
190 // Context menu should have a "copy link" item. 190 // Context menu should have a "copy link" item.
191 [[EarlGrey selectElementWithMatcher:copyItem] 191 [[EarlGrey selectElementWithMatcher:copyItem]
192 assertWithMatcher:grey_notNil()]; 192 assertWithMatcher:grey_notNil()];
193 193
194 // Dismiss the context menu. 194 // Dismiss the context menu.
195 [[EarlGrey selectElementWithMatcher:elementToDismissContextMenu(@"Cancel")] 195 [[EarlGrey selectElementWithMatcher:ElementToDismissContextMenu(@"Cancel")]
196 performAction:grey_tap()]; 196 performAction:grey_tap()];
197 197
198 // Context menu should go away after the tap. 198 // Context menu should go away after the tap.
199 [[EarlGrey selectElementWithMatcher:copyItem] assertWithMatcher:grey_nil()]; 199 [[EarlGrey selectElementWithMatcher:copyItem] assertWithMatcher:grey_nil()];
200 } 200 }
201 201
202 @end 202 @end
OLDNEW
« no previous file with comments | « ios/web/public/test/earl_grey/web_view_matchers.mm ('k') | ios/web/shell/test/earl_grey/shell_base_test_case.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698