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 <XCTest/XCTest.h> | 7 #import <XCTest/XCTest.h> |
8 | 8 |
9 #include "base/mac/scoped_nsobject.h" | |
10 #include "base/test/scoped_command_line.h" | 9 #include "base/test/scoped_command_line.h" |
11 #import "ios/chrome/app/main_controller_private.h" | 10 #import "ios/chrome/app/main_controller_private.h" |
12 #include "ios/chrome/browser/chrome_switches.h" | 11 #include "ios/chrome/browser/chrome_switches.h" |
13 #import "ios/chrome/browser/ui/commands/generic_chrome_command.h" | 12 #import "ios/chrome/browser/ui/commands/generic_chrome_command.h" |
14 #include "ios/chrome/browser/ui/commands/ios_command_ids.h" | 13 #include "ios/chrome/browser/ui/commands/ios_command_ids.h" |
15 #import "ios/chrome/browser/ui/tools_menu/tools_menu_view_controller.h" | 14 #import "ios/chrome/browser/ui/tools_menu/tools_menu_view_controller.h" |
16 #import "ios/chrome/browser/ui/ui_util.h" | 15 #import "ios/chrome/browser/ui/ui_util.h" |
17 #include "ios/chrome/grit/ios_strings.h" | 16 #include "ios/chrome/grit/ios_strings.h" |
18 #import "ios/chrome/test/app/chrome_test_util.h" | 17 #import "ios/chrome/test/app/chrome_test_util.h" |
19 #import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h" | 18 #import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h" |
20 #import "ios/chrome/test/earl_grey/chrome_matchers.h" | 19 #import "ios/chrome/test/earl_grey/chrome_matchers.h" |
21 #import "ios/chrome/test/earl_grey/chrome_test_case.h" | 20 #import "ios/chrome/test/earl_grey/chrome_test_case.h" |
22 #include "ui/base/l10n/l10n_util.h" | 21 #include "ui/base/l10n/l10n_util.h" |
23 | 22 |
| 23 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 24 #error "This file requires ARC support." |
| 25 #endif |
| 26 |
24 using chrome_test_util::ButtonWithAccessibilityLabel; | 27 using chrome_test_util::ButtonWithAccessibilityLabel; |
25 using chrome_test_util::ButtonWithAccessibilityLabelId; | 28 using chrome_test_util::ButtonWithAccessibilityLabelId; |
26 using chrome_test_util::StaticTextWithAccessibilityLabelId; | 29 using chrome_test_util::StaticTextWithAccessibilityLabelId; |
27 | 30 |
28 namespace { | 31 namespace { |
29 | 32 |
30 // Returns the GREYMatcher for the button that closes the tab switcher. | 33 // Returns the GREYMatcher for the button that closes the tab switcher. |
31 id<GREYMatcher> TabSwitcherCloseButton() { | 34 id<GREYMatcher> TabSwitcherCloseButton() { |
32 return ButtonWithAccessibilityLabelId(IDS_IOS_TAB_STRIP_LEAVE_TAB_SWITCHER); | 35 return ButtonWithAccessibilityLabelId(IDS_IOS_TAB_STRIP_LEAVE_TAB_SWITCHER); |
33 } | 36 } |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 [ChromeEarlGreyUI openToolsMenu]; | 69 [ChromeEarlGreyUI openToolsMenu]; |
67 id<GREYMatcher> newIncognitoTabButtonMatcher = | 70 id<GREYMatcher> newIncognitoTabButtonMatcher = |
68 grey_accessibilityID(kToolsMenuNewIncognitoTabId); | 71 grey_accessibilityID(kToolsMenuNewIncognitoTabId); |
69 [[EarlGrey selectElementWithMatcher:newIncognitoTabButtonMatcher] | 72 [[EarlGrey selectElementWithMatcher:newIncognitoTabButtonMatcher] |
70 performAction:grey_tap()]; | 73 performAction:grey_tap()]; |
71 } | 74 } |
72 | 75 |
73 // Triggers the opening of the tab switcher by launching a command. Should be | 76 // Triggers the opening of the tab switcher by launching a command. Should be |
74 // called only when the tab switcher is not presented. | 77 // called only when the tab switcher is not presented. |
75 void EnterTabSwitcherWithCommand() { | 78 void EnterTabSwitcherWithCommand() { |
76 base::scoped_nsobject<GenericChromeCommand> command( | 79 GenericChromeCommand* command = |
77 [[GenericChromeCommand alloc] initWithTag:IDC_TOGGLE_TAB_SWITCHER]); | 80 [[GenericChromeCommand alloc] initWithTag:IDC_TOGGLE_TAB_SWITCHER]; |
78 chrome_test_util::RunCommandWithActiveViewController(command); | 81 chrome_test_util::RunCommandWithActiveViewController(command); |
79 } | 82 } |
80 | 83 |
81 } // namespace | 84 } // namespace |
82 | 85 |
83 @interface TabSwitcherControllerTestCase : ChromeTestCase | 86 @interface TabSwitcherControllerTestCase : ChromeTestCase |
84 @end | 87 @end |
85 | 88 |
86 @implementation TabSwitcherControllerTestCase { | 89 @implementation TabSwitcherControllerTestCase { |
87 std::unique_ptr<base::test::ScopedCommandLine> scoped_command_line_; | 90 std::unique_ptr<base::test::ScopedCommandLine> scoped_command_line_; |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 | 215 |
213 // Press the :: icon to exit the tab switcher. | 216 // Press the :: icon to exit the tab switcher. |
214 [[EarlGrey selectElementWithMatcher:TabSwitcherCloseButton()] | 217 [[EarlGrey selectElementWithMatcher:TabSwitcherCloseButton()] |
215 performAction:grey_tap()]; | 218 performAction:grey_tap()]; |
216 | 219 |
217 // Verify that we've left the tab switcher. | 220 // Verify that we've left the tab switcher. |
218 [self assertTabSwitcherIsInactive]; | 221 [self assertTabSwitcherIsInactive]; |
219 } | 222 } |
220 | 223 |
221 @end | 224 @end |
OLD | NEW |