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 "components/strings/grit/components_strings.h" | 8 #include "components/strings/grit/components_strings.h" |
9 #import "ios/chrome/browser/ui/commands/generic_chrome_command.h" | 9 #import "ios/chrome/browser/ui/commands/generic_chrome_command.h" |
10 #include "ios/chrome/browser/ui/commands/ios_command_ids.h" | 10 #include "ios/chrome/browser/ui/commands/ios_command_ids.h" |
11 #import "ios/chrome/browser/ui/ntp/new_tab_page_controller.h" | 11 #import "ios/chrome/browser/ui/ntp/new_tab_page_controller.h" |
12 #include "ios/chrome/browser/ui/ui_util.h" | 12 #include "ios/chrome/browser/ui/ui_util.h" |
13 #include "ios/chrome/grit/ios_strings.h" | 13 #include "ios/chrome/grit/ios_strings.h" |
14 #import "ios/chrome/test/app/chrome_test_util.h" | 14 #import "ios/chrome/test/app/chrome_test_util.h" |
15 #import "ios/chrome/test/app/tab_test_util.h" | 15 #import "ios/chrome/test/app/tab_test_util.h" |
16 #import "ios/chrome/test/earl_grey/accessibility_util.h" | 16 #import "ios/chrome/test/earl_grey/accessibility_util.h" |
17 #import "ios/chrome/test/earl_grey/chrome_matchers.h" | 17 #import "ios/chrome/test/earl_grey/chrome_matchers.h" |
18 #import "ios/chrome/test/earl_grey/chrome_test_case.h" | 18 #import "ios/chrome/test/earl_grey/chrome_test_case.h" |
19 #import "ios/testing/wait_util.h" | 19 #import "ios/testing/wait_util.h" |
20 #include "ui/base/l10n/l10n_util.h" | 20 #include "ui/base/l10n/l10n_util.h" |
21 | 21 |
22 #if !defined(__has_feature) || !__has_feature(objc_arc) | 22 #if !defined(__has_feature) || !__has_feature(objc_arc) |
23 #error "This file requires ARC support." | 23 #error "This file requires ARC support." |
24 #endif | 24 #endif |
25 | 25 |
26 @implementation NewTabPageController (ExposedForTesting) | 26 @implementation NewTabPageController (ExposedForTesting) |
27 - (GoogleLandingController*)googleLandingController { | 27 - (GoogleLandingViewController*)googleLandingController { |
28 return googleLandingController_; | 28 return googleLandingController_; |
29 } | 29 } |
30 @end | 30 @end |
31 | 31 |
32 @interface GoogleLandingController (ExposedForTesting) | 32 @interface GoogleLandingViewController (ExposedForTesting) |
33 - (BOOL)scrolledToTop; | 33 - (BOOL)scrolledToTop; |
34 - (BOOL)animateHeader; | 34 - (BOOL)animateHeader; |
35 @end | 35 @end |
36 | 36 |
37 namespace { | 37 namespace { |
38 | 38 |
39 void DismissNewTabPagePanel() { | 39 void DismissNewTabPagePanel() { |
40 if (!IsIPadIdiom()) { | 40 if (!IsIPadIdiom()) { |
41 id<GREYMatcher> matcher = grey_allOf(grey_accessibilityID(@"Exit"), | 41 id<GREYMatcher> matcher = grey_allOf(grey_accessibilityID(@"Exit"), |
42 grey_sufficientlyVisible(), nil); | 42 grey_sufficientlyVisible(), nil); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 chrome_test_util::RunCommandWithActiveViewController(command); | 81 chrome_test_util::RunCommandWithActiveViewController(command); |
82 } | 82 } |
83 } | 83 } |
84 [[GREYUIThreadExecutor sharedInstance] drainUntilIdle]; | 84 [[GREYUIThreadExecutor sharedInstance] drainUntilIdle]; |
85 } | 85 } |
86 | 86 |
87 void AssertNTPScrolledToTop(bool scrolledToTop) { | 87 void AssertNTPScrolledToTop(bool scrolledToTop) { |
88 [[GREYUIThreadExecutor sharedInstance] drainUntilIdle]; | 88 [[GREYUIThreadExecutor sharedInstance] drainUntilIdle]; |
89 NewTabPageController* ntp_controller = | 89 NewTabPageController* ntp_controller = |
90 chrome_test_util::GetCurrentNewTabPageController(); | 90 chrome_test_util::GetCurrentNewTabPageController(); |
91 GoogleLandingController* google_landing_controller = | 91 GoogleLandingViewController* google_landing_view_controller = |
92 [ntp_controller googleLandingController]; | 92 [ntp_controller googleLandingController]; |
93 [[GREYCondition | 93 [[GREYCondition |
94 conditionWithName:@"Wait for end of animation." | 94 conditionWithName:@"Wait for end of animation." |
95 block:^BOOL { | 95 block:^BOOL { |
96 return ![google_landing_controller animateHeader]; | 96 return ![google_landing_view_controller animateHeader]; |
97 }] waitWithTimeout:testing::kWaitForUIElementTimeout]; | 97 }] waitWithTimeout:testing::kWaitForUIElementTimeout]; |
98 GREYAssertTrue([google_landing_controller scrolledToTop] == scrolledToTop, | 98 GREYAssertTrue( |
99 @"scrolledToTop_ does not match expected value"); | 99 [google_landing_view_controller scrolledToTop] == scrolledToTop, |
| 100 @"scrolledToTop_ does not match expected value"); |
100 } | 101 } |
101 | 102 |
102 } // namespace | 103 } // namespace |
103 | 104 |
104 @interface UIWindow (Hidden) | 105 @interface UIWindow (Hidden) |
105 - (UIResponder*)firstResponder; | 106 - (UIResponder*)firstResponder; |
106 @end | 107 @end |
107 | 108 |
108 @interface NewTabPageTestCase : ChromeTestCase | 109 @interface NewTabPageTestCase : ChromeTestCase |
109 @end | 110 @end |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 AssertNTPScrolledToTop(YES); | 304 AssertNTPScrolledToTop(YES); |
304 | 305 |
305 // Check that tab switcher and tools menu buttons are not on screen. | 306 // Check that tab switcher and tools menu buttons are not on screen. |
306 [[EarlGrey selectElementWithMatcher:chrome_test_util::ShowTabsButton()] | 307 [[EarlGrey selectElementWithMatcher:chrome_test_util::ShowTabsButton()] |
307 assertWithMatcher:grey_notVisible()]; | 308 assertWithMatcher:grey_notVisible()]; |
308 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(toolsMenuLabel)] | 309 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(toolsMenuLabel)] |
309 assertWithMatcher:grey_notVisible()]; | 310 assertWithMatcher:grey_notVisible()]; |
310 } | 311 } |
311 | 312 |
312 @end | 313 @end |
OLD | NEW |