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 <XCTest/XCTest.h> | 6 #import <XCTest/XCTest.h> |
7 | 7 |
8 #include "base/ios/ios_util.h" | 8 #include "base/ios/ios_util.h" |
9 #include "components/strings/grit/components_strings.h" | 9 #include "components/strings/grit/components_strings.h" |
10 #import "ios/chrome/browser/ui/commands/generic_chrome_command.h" | 10 #import "ios/chrome/browser/ui/commands/generic_chrome_command.h" |
11 #include "ios/chrome/browser/ui/commands/ios_command_ids.h" | 11 #include "ios/chrome/browser/ui/commands/ios_command_ids.h" |
12 #import "ios/chrome/browser/ui/ntp/new_tab_page_controller.h" | 12 #import "ios/chrome/browser/ui/ntp/new_tab_page_controller.h" |
13 #import "ios/chrome/browser/ui/omnibox/omnibox_popup_material_row.h" | 13 #import "ios/chrome/browser/ui/omnibox/omnibox_popup_material_row.h" |
14 #import "ios/chrome/browser/ui/toolbar/toolbar_controller.h" | 14 #import "ios/chrome/browser/ui/toolbar/toolbar_controller.h" |
15 #import "ios/chrome/browser/ui/tools_menu/tools_menu_view_controller.h" | 15 #import "ios/chrome/browser/ui/tools_menu/tools_menu_view_controller.h" |
16 #include "ios/chrome/browser/ui/ui_util.h" | 16 #include "ios/chrome/browser/ui/ui_util.h" |
17 #include "ios/chrome/grit/ios_strings.h" | 17 #include "ios/chrome/grit/ios_strings.h" |
18 #import "ios/chrome/test/app/chrome_test_util.h" | 18 #import "ios/chrome/test/app/chrome_test_util.h" |
19 #import "ios/chrome/test/app/tab_test_util.h" | 19 #import "ios/chrome/test/app/tab_test_util.h" |
20 #import "ios/chrome/test/earl_grey/chrome_assertions.h" | 20 #import "ios/chrome/test/earl_grey/chrome_assertions.h" |
21 #import "ios/chrome/test/earl_grey/chrome_earl_grey.h" | 21 #import "ios/chrome/test/earl_grey/chrome_earl_grey.h" |
22 #import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h" | 22 #import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h" |
23 #import "ios/chrome/test/earl_grey/chrome_matchers.h" | 23 #import "ios/chrome/test/earl_grey/chrome_matchers.h" |
24 #import "ios/chrome/test/earl_grey/chrome_test_case.h" | 24 #import "ios/chrome/test/earl_grey/chrome_test_case.h" |
25 #import "ios/testing/earl_grey/disabled_test_macros.h" | 25 #import "ios/testing/earl_grey/disabled_test_macros.h" |
26 #import "ios/web/public/test/http_server.h" | 26 #import "ios/web/public/test/http_server.h" |
27 #include "ios/web/public/test/http_server_util.h" | 27 #include "ios/web/public/test/http_server_util.h" |
28 #include "ui/base/l10n/l10n_util_mac.h" | 28 #include "ui/base/l10n/l10n_util_mac.h" |
29 | 29 |
| 30 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 31 #error "This file requires ARC support." |
| 32 #endif |
| 33 |
30 using chrome_test_util::ButtonWithAccessibilityLabelId; | 34 using chrome_test_util::ButtonWithAccessibilityLabelId; |
31 using chrome_test_util::OmniboxText; | 35 using chrome_test_util::OmniboxText; |
32 using chrome_test_util::WebViewContainingText; | 36 using chrome_test_util::WebViewContainingText; |
33 | 37 |
34 // Toolbar integration tests for Chrome. | 38 // Toolbar integration tests for Chrome. |
35 @interface ToolbarTestCase : ChromeTestCase | 39 @interface ToolbarTestCase : ChromeTestCase |
36 @end | 40 @end |
37 | 41 |
38 namespace { | 42 namespace { |
39 | 43 |
40 // Displays the |panel_type| new tab page. On a phone this will send a command | 44 // Displays the |panel_type| new tab page. On a phone this will send a command |
41 // to display a dialog, on tablet this calls -selectPanel to slide the NTP. | 45 // to display a dialog, on tablet this calls -selectPanel to slide the NTP. |
42 void SelectNewTabPagePanel(NewTabPage::PanelIdentifier panel_type) { | 46 void SelectNewTabPagePanel(NewTabPage::PanelIdentifier panel_type) { |
43 NewTabPageController* ntp_controller = | 47 NewTabPageController* ntp_controller = |
44 chrome_test_util::GetCurrentNewTabPageController(); | 48 chrome_test_util::GetCurrentNewTabPageController(); |
45 if (IsIPadIdiom()) { | 49 if (IsIPadIdiom()) { |
46 [ntp_controller selectPanel:panel_type]; | 50 [ntp_controller selectPanel:panel_type]; |
47 } else { | 51 } else { |
48 NSUInteger tag = 0; | 52 NSUInteger tag = 0; |
49 if (panel_type == NewTabPage::PanelIdentifier::kBookmarksPanel) { | 53 if (panel_type == NewTabPage::PanelIdentifier::kBookmarksPanel) { |
50 tag = IDC_SHOW_BOOKMARK_MANAGER; | 54 tag = IDC_SHOW_BOOKMARK_MANAGER; |
51 } else if (panel_type == NewTabPage::PanelIdentifier::kOpenTabsPanel) { | 55 } else if (panel_type == NewTabPage::PanelIdentifier::kOpenTabsPanel) { |
52 tag = IDC_SHOW_OTHER_DEVICES; | 56 tag = IDC_SHOW_OTHER_DEVICES; |
53 } | 57 } |
54 if (tag) { | 58 if (tag) { |
55 base::scoped_nsobject<GenericChromeCommand> command( | 59 GenericChromeCommand* command = |
56 [[GenericChromeCommand alloc] initWithTag:tag]); | 60 [[GenericChromeCommand alloc] initWithTag:tag]; |
57 chrome_test_util::RunCommandWithActiveViewController(command); | 61 chrome_test_util::RunCommandWithActiveViewController(command); |
58 } | 62 } |
59 } | 63 } |
60 [[GREYUIThreadExecutor sharedInstance] drainUntilIdle]; | 64 [[GREYUIThreadExecutor sharedInstance] drainUntilIdle]; |
61 } | 65 } |
62 | 66 |
63 } // namespace | 67 } // namespace |
64 | 68 |
65 @implementation ToolbarTestCase | 69 @implementation ToolbarTestCase |
66 | 70 |
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 | 445 |
442 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(clearText)] | 446 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(clearText)] |
443 performAction:grey_tap()]; | 447 performAction:grey_tap()]; |
444 [[EarlGrey selectElementWithMatcher:chrome_test_util::Omnibox()] | 448 [[EarlGrey selectElementWithMatcher:chrome_test_util::Omnibox()] |
445 assertWithMatcher:chrome_test_util::OmniboxText("")]; | 449 assertWithMatcher:chrome_test_util::OmniboxText("")]; |
446 | 450 |
447 SelectNewTabPagePanel(NewTabPage::kMostVisitedPanel); | 451 SelectNewTabPagePanel(NewTabPage::kMostVisitedPanel); |
448 } | 452 } |
449 } | 453 } |
450 @end | 454 @end |
OLD | NEW |