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

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

Issue 2659163002: Re-enable web shell context menu EarlGrey tests. (Closed)
Patch Set: 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
(...skipping 15 matching lines...) Expand all
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.
37 #if TARGET_IPHONE_SIMULATOR
38 #define MAYBE_testContextMenu testContextMenu
39 #else
40 #define MAYBE_testContextMenu FLAKY_testContextMenu
41 #endif
42 // Tests context menu appears on a regular link. 36 // Tests context menu appears on a regular link.
43 - (void)MAYBE_testContextMenu { 37 - (void)testContextMenu {
44 // Create map of canned responses and set up the test HTML server. 38 // Create map of canned responses and set up the test HTML server.
45 std::map<GURL, std::string> responses; 39 std::map<GURL, std::string> responses;
46 GURL initialURL = web::test::HttpServer::MakeUrl("http://contextMenuOpen"); 40 GURL initialURL = web::test::HttpServer::MakeUrl("http://contextMenuOpen");
47 GURL destinationURL = web::test::HttpServer::MakeUrl("http://destination"); 41 GURL destinationURL = web::test::HttpServer::MakeUrl("http://destination");
48 // The initial page contains a link to the destination URL. 42 // The initial page contains a link to the destination URL.
49 std::string linkID = "link"; 43 std::string linkID = "link";
50 responses[initialURL] = 44 responses[initialURL] =
51 "<body>" 45 "<body>"
52 "<a href='" + 46 "<a href='" +
53 destinationURL.spec() + "' id='" + linkID + 47 destinationURL.spec() + "' id='" + linkID +
(...skipping 14 matching lines...) Expand all
68 assertWithMatcher:grey_notNil()]; 62 assertWithMatcher:grey_notNil()];
69 63
70 // Dismiss the context menu. 64 // Dismiss the context menu.
71 [[EarlGrey selectElementWithMatcher:ElementToDismissContextMenu(@"Cancel")] 65 [[EarlGrey selectElementWithMatcher:ElementToDismissContextMenu(@"Cancel")]
72 performAction:grey_tap()]; 66 performAction:grey_tap()];
73 67
74 // Context menu should go away after the tap. 68 // Context menu should go away after the tap.
75 [[EarlGrey selectElementWithMatcher:copyItem] assertWithMatcher:grey_nil()]; 69 [[EarlGrey selectElementWithMatcher:copyItem] assertWithMatcher:grey_nil()];
76 } 70 }
77 71
78 // TODO(crbug.com/675399): Re-enable this test on device.
79 #if TARGET_IPHONE_SIMULATOR
80 #define MAYBE_testContextMenuWebkitTouchCalloutNone \
81 testContextMenuWebkitTouchCalloutNone
82 #else
83 #define MAYBE_testContextMenuWebkitTouchCalloutNone \
84 FLAKY_testContextMenuWebkitTouchCalloutNone
85 #endif
86 // Tests context menu on element that has WebkitTouchCallout set to none. 72 // Tests context menu on element that has WebkitTouchCallout set to none.
87 - (void)MAYBE_testContextMenuWebkitTouchCalloutNone { 73 - (void)testContextMenuWebkitTouchCalloutNone {
88 // Create map of canned responses and set up the test HTML server. 74 // Create map of canned responses and set up the test HTML server.
89 std::map<GURL, std::string> responses; 75 std::map<GURL, std::string> responses;
90 GURL initialURL = 76 GURL initialURL =
91 web::test::HttpServer::MakeUrl("http://contextMenuDisabledByWebkit"); 77 web::test::HttpServer::MakeUrl("http://contextMenuDisabledByWebkit");
92 GURL destinationURL = web::test::HttpServer::MakeUrl("http://destination"); 78 GURL destinationURL = web::test::HttpServer::MakeUrl("http://destination");
93 // The initial page contains a link to the destination URL that has an 79 // The initial page contains a link to the destination URL that has an
94 // ancestor that disables the context menu via -webkit-touch-callout. 80 // ancestor that disables the context menu via -webkit-touch-callout.
95 std::string linkID = "link"; 81 std::string linkID = "link";
96 responses[initialURL] = "<body><a href='" + destinationURL.spec() + 82 responses[initialURL] = "<body><a href='" + destinationURL.spec() +
97 "' style='-webkit-touch-callout: none' id='" + 83 "' style='-webkit-touch-callout: none' id='" +
98 linkID + 84 linkID +
99 "'>no-callout link</a>" 85 "'>no-callout link</a>"
100 "</body>"; 86 "</body>";
101 87
102 web::test::SetUpSimpleHttpServer(responses); 88 web::test::SetUpSimpleHttpServer(responses);
103 [ShellEarlGrey loadURL:initialURL]; 89 [ShellEarlGrey loadURL:initialURL];
104 90
105 [[EarlGrey selectElementWithMatcher:web::WebView()] 91 [[EarlGrey selectElementWithMatcher:web::WebView()]
106 performAction:web::longPressElementForContextMenu( 92 performAction:web::longPressElementForContextMenu(
107 linkID, false /* menu shouldn't appear */)]; 93 linkID, false /* menu shouldn't appear */)];
108 94
109 id<GREYMatcher> copyItem = ContextMenuItemWithText(@"Copy Link"); 95 id<GREYMatcher> copyItem = ContextMenuItemWithText(@"Copy Link");
110 96
111 // Verify no context menu. 97 // Verify no context menu.
112 [[EarlGrey selectElementWithMatcher:copyItem] assertWithMatcher:grey_nil()]; 98 [[EarlGrey selectElementWithMatcher:copyItem] assertWithMatcher:grey_nil()];
113 } 99 }
114 100
115 // TODO(crbug.com/675399): Re-enable this test on device.
116 #if TARGET_IPHONE_SIMULATOR
117 #define MAYBE_testContextMenuWebkitTouchCalloutNoneFromAncestor \
118 testContextMenuWebkitTouchCalloutNoneFromAncestor
119 #else
120 #define MAYBE_testContextMenuWebkitTouchCalloutNoneFromAncestor \
121 FLAKY_testContextMenuWebkitTouchCalloutNoneFromAncestor
122 #endif
123 // Tests context menu on element that has WebkitTouchCallout set to none from an 101 // Tests context menu on element that has WebkitTouchCallout set to none from an
124 // ancestor. 102 // ancestor.
125 - (void)MAYBE_testContextMenuWebkitTouchCalloutNoneFromAncestor { 103 - (void)testContextMenuWebkitTouchCalloutNoneFromAncestor {
126 // Create map of canned responses and set up the test HTML server. 104 // Create map of canned responses and set up the test HTML server.
127 std::map<GURL, std::string> responses; 105 std::map<GURL, std::string> responses;
128 GURL initialURL = 106 GURL initialURL =
129 web::test::HttpServer::MakeUrl("http://contextMenuDisabledByWebkit"); 107 web::test::HttpServer::MakeUrl("http://contextMenuDisabledByWebkit");
130 GURL destinationURL = web::test::HttpServer::MakeUrl("http://destination"); 108 GURL destinationURL = web::test::HttpServer::MakeUrl("http://destination");
131 // The initial page contains a link to the destination URL that has an 109 // The initial page contains a link to the destination URL that has an
132 // ancestor that disables the context menu via -webkit-touch-callout. 110 // ancestor that disables the context menu via -webkit-touch-callout.
133 std::string linkID = "link"; 111 std::string linkID = "link";
134 responses[initialURL] = 112 responses[initialURL] =
135 "<body style='-webkit-touch-callout: none'>" 113 "<body style='-webkit-touch-callout: none'>"
136 "<a href='" + 114 "<a href='" +
137 destinationURL.spec() + "' id='" + linkID + 115 destinationURL.spec() + "' id='" + linkID +
138 "'>ancestor no-callout link</a>" 116 "'>ancestor no-callout link</a>"
139 "</body>"; 117 "</body>";
140 118
141 web::test::SetUpSimpleHttpServer(responses); 119 web::test::SetUpSimpleHttpServer(responses);
142 [ShellEarlGrey loadURL:initialURL]; 120 [ShellEarlGrey loadURL:initialURL];
143 121
144 [[EarlGrey selectElementWithMatcher:web::WebView()] 122 [[EarlGrey selectElementWithMatcher:web::WebView()]
145 performAction:web::longPressElementForContextMenu( 123 performAction:web::longPressElementForContextMenu(
146 linkID, false /* menu shouldn't appear */)]; 124 linkID, false /* menu shouldn't appear */)];
147 125
148 id<GREYMatcher> copyItem = ContextMenuItemWithText(@"Copy Link"); 126 id<GREYMatcher> copyItem = ContextMenuItemWithText(@"Copy Link");
149 127
150 // Verify no context menu. 128 // Verify no context menu.
151 [[EarlGrey selectElementWithMatcher:copyItem] assertWithMatcher:grey_nil()]; 129 [[EarlGrey selectElementWithMatcher:copyItem] assertWithMatcher:grey_nil()];
152 } 130 }
153 131
154 // TODO(crbug.com/675399): Re-enable this test on device.
155 #if TARGET_IPHONE_SIMULATOR
156 #define MAYBE_testContextMenuWebkitTouchCalloutOverride \
157 testContextMenuWebkitTouchCalloutOverride
158 #else
159 #define MAYBE_testContextMenuWebkitTouchCalloutOverride \
160 FLAKY_testContextMenuWebkitTouchCalloutOverride
161 #endif
162 // Tests context menu on element that has WebkitTouchCallout set to none from an 132 // Tests context menu on element that has WebkitTouchCallout set to none from an
163 // ancestor and overridden. 133 // ancestor and overridden.
164 - (void)MAYBE_testContextMenuWebkitTouchCalloutOverride { 134 - (void)testContextMenuWebkitTouchCalloutOverride {
165 // Create map of canned responses and set up the test HTML server. 135 // Create map of canned responses and set up the test HTML server.
166 std::map<GURL, std::string> responses; 136 std::map<GURL, std::string> responses;
167 GURL initialURL = 137 GURL initialURL =
168 web::test::HttpServer::MakeUrl("http://contextMenuDisabledByWebkit"); 138 web::test::HttpServer::MakeUrl("http://contextMenuDisabledByWebkit");
169 GURL destinationURL = web::test::HttpServer::MakeUrl("http://destination"); 139 GURL destinationURL = web::test::HttpServer::MakeUrl("http://destination");
170 // The initial page contains a link to the destination URL that has an 140 // The initial page contains a link to the destination URL that has an
171 // ancestor that disables the context menu via -webkit-touch-callout. 141 // ancestor that disables the context menu via -webkit-touch-callout.
172 std::string linkID = "link"; 142 std::string linkID = "link";
173 responses[initialURL] = 143 responses[initialURL] =
174 "<body style='-webkit-touch-callout: none'>" 144 "<body style='-webkit-touch-callout: none'>"
(...skipping 18 matching lines...) Expand all
193 163
194 // Dismiss the context menu. 164 // Dismiss the context menu.
195 [[EarlGrey selectElementWithMatcher:ElementToDismissContextMenu(@"Cancel")] 165 [[EarlGrey selectElementWithMatcher:ElementToDismissContextMenu(@"Cancel")]
196 performAction:grey_tap()]; 166 performAction:grey_tap()];
197 167
198 // Context menu should go away after the tap. 168 // Context menu should go away after the tap.
199 [[EarlGrey selectElementWithMatcher:copyItem] assertWithMatcher:grey_nil()]; 169 [[EarlGrey selectElementWithMatcher:copyItem] assertWithMatcher:grey_nil()];
200 } 170 }
201 171
202 @end 172 @end
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698