| 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 "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h" | 5 #import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h" |
| 6 | 6 |
| 7 #import "ios/chrome/browser/ui/tools_menu/tools_menu_view_controller.h" | 7 #import "ios/chrome/browser/ui/tools_menu/tools_menu_view_controller.h" |
| 8 #import "ios/chrome/browser/ui/uikit_ui_util.h" | 8 #import "ios/chrome/browser/ui/uikit_ui_util.h" |
| 9 #import "ios/chrome/test/app/chrome_test_util.h" | 9 #import "ios/chrome/test/app/chrome_test_util.h" |
| 10 #include "ios/chrome/test/app/navigation_test_util.h" | 10 #include "ios/chrome/test/app/navigation_test_util.h" |
| 11 #import "ios/chrome/test/earl_grey/chrome_matchers.h" | 11 #import "ios/chrome/test/earl_grey/chrome_matchers.h" |
| 12 #import "ios/testing/wait_util.h" | 12 #import "ios/testing/wait_util.h" |
| 13 #import "ios/web/public/test/earl_grey/js_test_util.h" | 13 #import "ios/web/public/test/earl_grey/js_test_util.h" |
| 14 #import "ios/web/public/test/earl_grey/web_view_matchers.h" | 14 #import "ios/web/public/test/earl_grey/web_view_matchers.h" |
| 15 | 15 |
| 16 using testing::WaitUntilConditionOrTimeout; | 16 using testing::WaitUntilConditionOrTimeout; |
| 17 using testing::kWaitForPageLoadTimeout; | 17 using testing::kWaitForPageLoadTimeout; |
| 18 | 18 |
| 19 @implementation ChromeEarlGreyUI | 19 @implementation ChromeEarlGreyUI |
| 20 | 20 |
| 21 + (void)openToolsMenu { | 21 + (void)openToolsMenu { |
| 22 // TODO(crbug.com/639524): Add logic to ensure the app is in the correct | 22 // TODO(crbug.com/639524): Add logic to ensure the app is in the correct |
| 23 // state, for example DCHECK if no tabs are displayed. | 23 // state, for example DCHECK if no tabs are displayed. |
| 24 [[[EarlGrey | 24 [[[EarlGrey |
| 25 selectElementWithMatcher:grey_allOf(chrome_test_util::toolsMenuButton(), | 25 selectElementWithMatcher:grey_allOf(chrome_test_util::ToolsMenuButton(), |
| 26 grey_sufficientlyVisible(), nil)] | 26 grey_sufficientlyVisible(), nil)] |
| 27 usingSearchAction:grey_swipeSlowInDirection(kGREYDirectionDown) | 27 usingSearchAction:grey_swipeSlowInDirection(kGREYDirectionDown) |
| 28 onElementWithMatcher:web::webViewScrollView( | 28 onElementWithMatcher:web::WebViewScrollView( |
| 29 chrome_test_util::GetCurrentWebState())] | 29 chrome_test_util::GetCurrentWebState())] |
| 30 performAction:grey_tap()]; | 30 performAction:grey_tap()]; |
| 31 // TODO(crbug.com/639517): Add webViewScrollView matcher so we don't have | 31 // TODO(crbug.com/639517): Add webViewScrollView matcher so we don't have |
| 32 // to always find it. | 32 // to always find it. |
| 33 } | 33 } |
| 34 | 34 |
| 35 + (void)openNewTab { | 35 + (void)openNewTab { |
| 36 [ChromeEarlGreyUI openToolsMenu]; | 36 [ChromeEarlGreyUI openToolsMenu]; |
| 37 id<GREYMatcher> newTabButtonMatcher = | 37 id<GREYMatcher> newTabButtonMatcher = |
| 38 grey_accessibilityID(kToolsMenuNewTabId); | 38 grey_accessibilityID(kToolsMenuNewTabId); |
| 39 [[EarlGrey selectElementWithMatcher:newTabButtonMatcher] | 39 [[EarlGrey selectElementWithMatcher:newTabButtonMatcher] |
| 40 performAction:grey_tap()]; | 40 performAction:grey_tap()]; |
| 41 [[GREYUIThreadExecutor sharedInstance] drainUntilIdle]; | 41 [[GREYUIThreadExecutor sharedInstance] drainUntilIdle]; |
| 42 } | 42 } |
| 43 | 43 |
| 44 + (void)openNewIncognitoTab { | 44 + (void)openNewIncognitoTab { |
| 45 [ChromeEarlGreyUI openToolsMenu]; | 45 [ChromeEarlGreyUI openToolsMenu]; |
| 46 id<GREYMatcher> newIncognitoTabMatcher = | 46 id<GREYMatcher> newIncognitoTabMatcher = |
| 47 grey_accessibilityID(kToolsMenuNewIncognitoTabId); | 47 grey_accessibilityID(kToolsMenuNewIncognitoTabId); |
| 48 [[EarlGrey selectElementWithMatcher:newIncognitoTabMatcher] | 48 [[EarlGrey selectElementWithMatcher:newIncognitoTabMatcher] |
| 49 performAction:grey_tap()]; | 49 performAction:grey_tap()]; |
| 50 [[GREYUIThreadExecutor sharedInstance] drainUntilIdle]; | 50 [[GREYUIThreadExecutor sharedInstance] drainUntilIdle]; |
| 51 } | 51 } |
| 52 | 52 |
| 53 + (void)reload { | 53 + (void)reload { |
| 54 // On iPhone Reload button is a part of tools menu, so open it. | 54 // On iPhone Reload button is a part of tools menu, so open it. |
| 55 if (IsCompact()) { | 55 if (IsCompact()) { |
| 56 [self openToolsMenu]; | 56 [self openToolsMenu]; |
| 57 } | 57 } |
| 58 [[EarlGrey selectElementWithMatcher:chrome_test_util::reloadButton()] | 58 [[EarlGrey selectElementWithMatcher:chrome_test_util::ReloadButton()] |
| 59 performAction:grey_tap()]; | 59 performAction:grey_tap()]; |
| 60 } | 60 } |
| 61 | 61 |
| 62 + (void)openShareMenu { | 62 + (void)openShareMenu { |
| 63 if (IsCompact()) { | 63 if (IsCompact()) { |
| 64 [ChromeEarlGreyUI openToolsMenu]; | 64 [ChromeEarlGreyUI openToolsMenu]; |
| 65 } | 65 } |
| 66 [[EarlGrey selectElementWithMatcher:chrome_test_util::shareButton()] | 66 [[EarlGrey selectElementWithMatcher:chrome_test_util::ShareButton()] |
| 67 performAction:grey_tap()]; | 67 performAction:grey_tap()]; |
| 68 } | 68 } |
| 69 | 69 |
| 70 @end | 70 @end |
| OLD | NEW |