| 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 <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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 destinationURL.spec() + "' id='" + linkID + "'>" + linkText + | 49 destinationURL.spec() + "' id='" + linkID + "'>" + linkText + |
| 50 "</a>" | 50 "</a>" |
| 51 "</span></body>"; | 51 "</span></body>"; |
| 52 | 52 |
| 53 web::test::SetUpSimpleHttpServer(responses); | 53 web::test::SetUpSimpleHttpServer(responses); |
| 54 [ShellEarlGrey loadURL:initialURL]; | 54 [ShellEarlGrey loadURL:initialURL]; |
| 55 [[EarlGrey selectElementWithMatcher:WebViewContainingText(linkText)] | 55 [[EarlGrey selectElementWithMatcher:WebViewContainingText(linkText)] |
| 56 assertWithMatcher:grey_notNil()]; | 56 assertWithMatcher:grey_notNil()]; |
| 57 | 57 |
| 58 [[EarlGrey selectElementWithMatcher:web::WebView()] | 58 [[EarlGrey selectElementWithMatcher:web::WebView()] |
| 59 performAction:web::longPressElementForContextMenu( | 59 performAction:web::LongPressElementForContextMenu( |
| 60 linkID, true /* menu should appear */)]; | 60 linkID, true /* menu should appear */)]; |
| 61 | 61 |
| 62 id<GREYMatcher> copyItem = ContextMenuItemWithText(@"Copy Link"); | 62 id<GREYMatcher> copyItem = ContextMenuItemWithText(@"Copy Link"); |
| 63 | 63 |
| 64 // Context menu should have a "copy link" item. | 64 // Context menu should have a "copy link" item. |
| 65 [[EarlGrey selectElementWithMatcher:copyItem] | 65 [[EarlGrey selectElementWithMatcher:copyItem] |
| 66 assertWithMatcher:grey_notNil()]; | 66 assertWithMatcher:grey_notNil()]; |
| 67 | 67 |
| 68 // Dismiss the context menu. | 68 // Dismiss the context menu. |
| 69 [[EarlGrey selectElementWithMatcher:ElementToDismissContextMenu(@"Cancel")] | 69 [[EarlGrey selectElementWithMatcher:ElementToDismissContextMenu(@"Cancel")] |
| (...skipping 19 matching lines...) Expand all Loading... |
| 89 linkID + "'>" + linkText + | 89 linkID + "'>" + linkText + |
| 90 "</a>" | 90 "</a>" |
| 91 "</body>"; | 91 "</body>"; |
| 92 | 92 |
| 93 web::test::SetUpSimpleHttpServer(responses); | 93 web::test::SetUpSimpleHttpServer(responses); |
| 94 [ShellEarlGrey loadURL:initialURL]; | 94 [ShellEarlGrey loadURL:initialURL]; |
| 95 [[EarlGrey selectElementWithMatcher:WebViewContainingText(linkText)] | 95 [[EarlGrey selectElementWithMatcher:WebViewContainingText(linkText)] |
| 96 assertWithMatcher:grey_notNil()]; | 96 assertWithMatcher:grey_notNil()]; |
| 97 | 97 |
| 98 [[EarlGrey selectElementWithMatcher:web::WebView()] | 98 [[EarlGrey selectElementWithMatcher:web::WebView()] |
| 99 performAction:web::longPressElementForContextMenu( | 99 performAction:web::LongPressElementForContextMenu( |
| 100 linkID, false /* menu shouldn't appear */)]; | 100 linkID, false /* menu shouldn't appear */)]; |
| 101 | 101 |
| 102 id<GREYMatcher> copyItem = ContextMenuItemWithText(@"Copy Link"); | 102 id<GREYMatcher> copyItem = ContextMenuItemWithText(@"Copy Link"); |
| 103 | 103 |
| 104 // Verify no context menu. | 104 // Verify no context menu. |
| 105 [[EarlGrey selectElementWithMatcher:copyItem] assertWithMatcher:grey_nil()]; | 105 [[EarlGrey selectElementWithMatcher:copyItem] assertWithMatcher:grey_nil()]; |
| 106 } | 106 } |
| 107 | 107 |
| 108 // Tests context menu on element that has WebkitTouchCallout set to none from an | 108 // Tests context menu on element that has WebkitTouchCallout set to none from an |
| 109 // ancestor. | 109 // ancestor. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 123 destinationURL.spec() + "' id='" + linkID + "'>" + linkText + | 123 destinationURL.spec() + "' id='" + linkID + "'>" + linkText + |
| 124 "</a>" | 124 "</a>" |
| 125 "</body>"; | 125 "</body>"; |
| 126 | 126 |
| 127 web::test::SetUpSimpleHttpServer(responses); | 127 web::test::SetUpSimpleHttpServer(responses); |
| 128 [ShellEarlGrey loadURL:initialURL]; | 128 [ShellEarlGrey loadURL:initialURL]; |
| 129 [[EarlGrey selectElementWithMatcher:WebViewContainingText(linkText)] | 129 [[EarlGrey selectElementWithMatcher:WebViewContainingText(linkText)] |
| 130 assertWithMatcher:grey_notNil()]; | 130 assertWithMatcher:grey_notNil()]; |
| 131 | 131 |
| 132 [[EarlGrey selectElementWithMatcher:web::WebView()] | 132 [[EarlGrey selectElementWithMatcher:web::WebView()] |
| 133 performAction:web::longPressElementForContextMenu( | 133 performAction:web::LongPressElementForContextMenu( |
| 134 linkID, false /* menu shouldn't appear */)]; | 134 linkID, false /* menu shouldn't appear */)]; |
| 135 | 135 |
| 136 id<GREYMatcher> copyItem = ContextMenuItemWithText(@"Copy Link"); | 136 id<GREYMatcher> copyItem = ContextMenuItemWithText(@"Copy Link"); |
| 137 | 137 |
| 138 // Verify no context menu. | 138 // Verify no context menu. |
| 139 [[EarlGrey selectElementWithMatcher:copyItem] assertWithMatcher:grey_nil()]; | 139 [[EarlGrey selectElementWithMatcher:copyItem] assertWithMatcher:grey_nil()]; |
| 140 } | 140 } |
| 141 | 141 |
| 142 // Tests context menu on element that has WebkitTouchCallout set to none from an | 142 // Tests context menu on element that has WebkitTouchCallout set to none from an |
| 143 // ancestor and overridden. | 143 // ancestor and overridden. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 158 linkID + "'>" + linkText + | 158 linkID + "'>" + linkText + |
| 159 "</a>" | 159 "</a>" |
| 160 "</body>"; | 160 "</body>"; |
| 161 | 161 |
| 162 web::test::SetUpSimpleHttpServer(responses); | 162 web::test::SetUpSimpleHttpServer(responses); |
| 163 [ShellEarlGrey loadURL:initialURL]; | 163 [ShellEarlGrey loadURL:initialURL]; |
| 164 [[EarlGrey selectElementWithMatcher:WebViewContainingText(linkText)] | 164 [[EarlGrey selectElementWithMatcher:WebViewContainingText(linkText)] |
| 165 assertWithMatcher:grey_notNil()]; | 165 assertWithMatcher:grey_notNil()]; |
| 166 | 166 |
| 167 [[EarlGrey selectElementWithMatcher:web::WebView()] | 167 [[EarlGrey selectElementWithMatcher:web::WebView()] |
| 168 performAction:web::longPressElementForContextMenu( | 168 performAction:web::LongPressElementForContextMenu( |
| 169 linkID, true /* menu should appear */)]; | 169 linkID, true /* menu should appear */)]; |
| 170 | 170 |
| 171 id<GREYMatcher> copyItem = ContextMenuItemWithText(@"Copy Link"); | 171 id<GREYMatcher> copyItem = ContextMenuItemWithText(@"Copy Link"); |
| 172 | 172 |
| 173 // Context menu should have a "copy link" item. | 173 // Context menu should have a "copy link" item. |
| 174 [[EarlGrey selectElementWithMatcher:copyItem] | 174 [[EarlGrey selectElementWithMatcher:copyItem] |
| 175 assertWithMatcher:grey_notNil()]; | 175 assertWithMatcher:grey_notNil()]; |
| 176 | 176 |
| 177 // Dismiss the context menu. | 177 // Dismiss the context menu. |
| 178 [[EarlGrey selectElementWithMatcher:ElementToDismissContextMenu(@"Cancel")] | 178 [[EarlGrey selectElementWithMatcher:ElementToDismissContextMenu(@"Cancel")] |
| 179 performAction:grey_tap()]; | 179 performAction:grey_tap()]; |
| 180 | 180 |
| 181 // Context menu should go away after the tap. | 181 // Context menu should go away after the tap. |
| 182 [[EarlGrey selectElementWithMatcher:copyItem] assertWithMatcher:grey_nil()]; | 182 [[EarlGrey selectElementWithMatcher:copyItem] assertWithMatcher:grey_nil()]; |
| 183 } | 183 } |
| 184 | 184 |
| 185 @end | 185 @end |
| OLD | NEW |