| 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 15 matching lines...) Expand all Loading... |
| 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/675015): 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 |
| 39 #else | 39 #else |
| 40 #define MAYBE_testContextMenu FLAKY_testContextMenu | 40 #define MAYBE_testContextMenu FLAKY_testContextMenu |
| 41 #endif | 41 #endif |
| 42 // Tests context menu appears on a regular link. | 42 // Tests context menu appears on a regular link. |
| 43 - (void)MAYBE_testContextMenu { | 43 - (void)MAYBE_testContextMenu { |
| 44 // Create map of canned responses and set up the test HTML server. | 44 // Create map of canned responses and set up the test HTML server. |
| 45 std::map<GURL, std::string> responses; | 45 std::map<GURL, std::string> responses; |
| 46 GURL initialURL = web::test::HttpServer::MakeUrl("http://contextMenuOpen"); | 46 GURL initialURL = web::test::HttpServer::MakeUrl("http://contextMenuOpen"); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 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/675015): 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 |
| 82 #else | 82 #else |
| 83 #define MAYBE_testContextMenuWebkitTouchCalloutNone \ | 83 #define MAYBE_testContextMenuWebkitTouchCalloutNone \ |
| 84 FLAKY_testContextMenuWebkitTouchCalloutNone | 84 FLAKY_testContextMenuWebkitTouchCalloutNone |
| 85 #endif | 85 #endif |
| 86 // Tests context menu on element that has WebkitTouchCallout set to none. | 86 // Tests context menu on element that has WebkitTouchCallout set to none. |
| 87 - (void)MAYBE_testContextMenuWebkitTouchCalloutNone { | 87 - (void)MAYBE_testContextMenuWebkitTouchCalloutNone { |
| 88 // Create map of canned responses and set up the test HTML server. | 88 // Create map of canned responses and set up the test HTML server. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 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/675015): 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 |
| 120 #define MAYBE_testContextMenuWebkitTouchCalloutNoneFromAncestor \ | 120 #define MAYBE_testContextMenuWebkitTouchCalloutNoneFromAncestor \ |
| 121 FLAKY_testContextMenuWebkitTouchCalloutNoneFromAncestor | 121 FLAKY_testContextMenuWebkitTouchCalloutNoneFromAncestor |
| 122 #endif | 122 #endif |
| 123 // Tests context menu on element that has WebkitTouchCallout set to none from an | 123 // Tests context menu on element that has WebkitTouchCallout set to none from an |
| 124 // ancestor. | 124 // ancestor. |
| 125 - (void)MAYBE_testContextMenuWebkitTouchCalloutNoneFromAncestor { | 125 - (void)MAYBE_testContextMenuWebkitTouchCalloutNoneFromAncestor { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 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/675015): 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 |
| 159 #define MAYBE_testContextMenuWebkitTouchCalloutOverride \ | 159 #define MAYBE_testContextMenuWebkitTouchCalloutOverride \ |
| 160 FLAKY_testContextMenuWebkitTouchCalloutOverride | 160 FLAKY_testContextMenuWebkitTouchCalloutOverride |
| 161 #endif | 161 #endif |
| 162 // Tests context menu on element that has WebkitTouchCallout set to none from an | 162 // Tests context menu on element that has WebkitTouchCallout set to none from an |
| 163 // ancestor and overridden. | 163 // ancestor and overridden. |
| 164 - (void)MAYBE_testContextMenuWebkitTouchCalloutOverride { | 164 - (void)MAYBE_testContextMenuWebkitTouchCalloutOverride { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 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 |
| OLD | NEW |