Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(123)

Side by Side Diff: ios/chrome/browser/metrics/tab_usage_recorder_egtest.mm

Issue 2732973003: Use shared matchers for common elements. (Closed)
Patch Set: clean up format with using Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/mac/bind_objc_block.h" 8 #include "base/mac/bind_objc_block.h"
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 // Select the non incognito panel. 172 // Select the non incognito panel.
173 id<GREYMatcher> tabSwitcherHeaderPanelButton = 173 id<GREYMatcher> tabSwitcherHeaderPanelButton =
174 grey_accessibilityLabel(l10n_util::GetNSStringWithFixup( 174 grey_accessibilityLabel(l10n_util::GetNSStringWithFixup(
175 IDS_IOS_TAB_SWITCHER_HEADER_NON_INCOGNITO_TABS)); 175 IDS_IOS_TAB_SWITCHER_HEADER_NON_INCOGNITO_TABS));
176 [[EarlGrey selectElementWithMatcher:tabSwitcherHeaderPanelButton] 176 [[EarlGrey selectElementWithMatcher:tabSwitcherHeaderPanelButton]
177 performAction:grey_tap()]; 177 performAction:grey_tap()];
178 178
179 // Leave the tab switcher. 179 // Leave the tab switcher.
180 CloseTabSwitcher(); 180 CloseTabSwitcher();
181 } else { 181 } else {
182 [[EarlGrey selectElementWithMatcher: 182 [[EarlGrey selectElementWithMatcher:chrome_test_util::ShowTabsButton()]
183 chrome_test_util::ButtonWithAccessibilityLabelId( 183 performAction:grey_tap()];
184 IDS_IOS_TOOLBAR_SHOW_TABS)] performAction:grey_tap()];
185 [[EarlGrey selectElementWithMatcher: 184 [[EarlGrey selectElementWithMatcher:
186 chrome_test_util::ButtonWithAccessibilityLabelId( 185 chrome_test_util::ButtonWithAccessibilityLabelId(
187 IDS_IOS_TOOLS_MENU_NEW_INCOGNITO_TAB)] 186 IDS_IOS_TOOLS_MENU_NEW_INCOGNITO_TAB)]
188 performAction:grey_swipeSlowInDirection(kGREYDirectionRight)]; 187 performAction:grey_swipeSlowInDirection(kGREYDirectionRight)];
189 [[EarlGrey selectElementWithMatcher: 188 [[EarlGrey selectElementWithMatcher:chrome_test_util::ShowTabsButton()]
190 chrome_test_util::ButtonWithAccessibilityLabelId( 189 performAction:grey_tap()];
191 IDS_IOS_TOOLBAR_SHOW_TABS)] performAction:grey_tap()];
192 } 190 }
193 ConditionBlock condition = ^bool { 191 ConditionBlock condition = ^bool {
194 return !chrome_test_util::IsIncognitoMode(); 192 return !chrome_test_util::IsIncognitoMode();
195 }; 193 };
196 GREYAssert( 194 GREYAssert(
197 testing::WaitUntilConditionOrTimeout(kWaitElementTimeout, condition), 195 testing::WaitUntilConditionOrTimeout(kWaitElementTimeout, condition),
198 @"Waiting switch to normal mode."); 196 @"Waiting switch to normal mode.");
199 } 197 }
200 198
201 // Check that the error page is visible. 199 // Check that the error page is visible.
(...skipping 26 matching lines...) Expand all
228 grey_accessibilityID(kToolsMenuSettingsId); 226 grey_accessibilityID(kToolsMenuSettingsId);
229 227
230 WaitAndTap(settings_button_matcher, @"Settings menu"); 228 WaitAndTap(settings_button_matcher, @"Settings menu");
231 Wait(grey_accessibilityID(kSettingsCollectionViewId), @"Setting view"); 229 Wait(grey_accessibilityID(kSettingsCollectionViewId), @"Setting view");
232 } 230 }
233 231
234 // Select the tab with title |title| using UI (tab strip on iPad, stack view on 232 // Select the tab with title |title| using UI (tab strip on iPad, stack view on
235 // iPhone). 233 // iPhone).
236 void SelectTabUsingUI(NSString* title) { 234 void SelectTabUsingUI(NSString* title) {
237 if (IsCompact()) { 235 if (IsCompact()) {
238 WaitAndTap(chrome_test_util::ButtonWithAccessibilityLabelId( 236 WaitAndTap(chrome_test_util::ShowTabsButton(), @"Tab switcher");
239 IDS_IOS_TOOLBAR_SHOW_TABS),
240 @"Tab switcher");
241 } 237 }
242 WaitAndTap(grey_text(title), 238 WaitAndTap(grey_text(title),
243 [NSString stringWithFormat:@"tab with title %@", title]); 239 [NSString stringWithFormat:@"tab with title %@", title]);
244 } 240 }
245 } // namespace 241 } // namespace
246 242
247 // Test for the TabUsageRecorder class. 243 // Test for the TabUsageRecorder class.
248 @interface TabUsageRecorderTestCase : ChromeTestCase 244 @interface TabUsageRecorderTestCase : ChromeTestCase
249 @end 245 @end
250 246
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after
853 849
854 // Open a tab with a link to click. 850 // Open a tab with a link to click.
855 NewMainTabWithURL(initialURL, "link"); 851 NewMainTabWithURL(initialURL, "link");
856 852
857 int numberOfTabs = chrome_test_util::GetMainTabCount(); 853 int numberOfTabs = chrome_test_util::GetMainTabCount();
858 [[EarlGrey 854 [[EarlGrey
859 selectElementWithMatcher:chrome_test_util::WebViewContainingText("link")] 855 selectElementWithMatcher:chrome_test_util::WebViewContainingText("link")]
860 performAction:grey_longPress()]; 856 performAction:grey_longPress()];
861 857
862 [[EarlGrey 858 [[EarlGrey
863 selectElementWithMatcher:grey_text(l10n_util::GetNSString( 859 selectElementWithMatcher:chrome_test_util::OpenLinkInNewTabMenuItem()]
864 IDS_IOS_CONTENT_CONTEXT_OPENLINKNEWTAB))]
865 performAction:grey_tap()]; 860 performAction:grey_tap()];
866 chrome_test_util::AssertMainTabCount(numberOfTabs + 1); 861 chrome_test_util::AssertMainTabCount(numberOfTabs + 1);
867 862
868 SelectTabUsingUI(base::SysUTF8ToNSString(destinationURL.GetContent())); 863 SelectTabUsingUI(base::SysUTF8ToNSString(destinationURL.GetContent()));
869 864
870 [[GREYUIThreadExecutor sharedInstance] drainUntilIdle]; 865 [[GREYUIThreadExecutor sharedInstance] drainUntilIdle];
871 [[EarlGrey 866 [[EarlGrey
872 selectElementWithMatcher:chrome_test_util::WebViewContainingText("Whee")] 867 selectElementWithMatcher:chrome_test_util::WebViewContainingText("Whee")]
873 assertWithMatcher:grey_notNil()]; 868 assertWithMatcher:grey_notNil()];
874 869
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
944 [[GREYUIThreadExecutor sharedInstance] drainUntilIdle]; 939 [[GREYUIThreadExecutor sharedInstance] drainUntilIdle];
945 } 940 }
946 // The deleted tabs are purged during foregrounding and backgrounding. 941 // The deleted tabs are purged during foregrounding and backgrounding.
947 chrome_test_util::SimulateTabsBackgrounding(); 942 chrome_test_util::SimulateTabsBackgrounding();
948 // Make sure |evicted_tabs_| purged the deleted tabs. 943 // Make sure |evicted_tabs_| purged the deleted tabs.
949 int evicted = chrome_test_util::GetEvictedMainTabCount(); 944 int evicted = chrome_test_util::GetEvictedMainTabCount();
950 GREYAssertEqual(evicted, 0, @"Check number of evicted tabs"); 945 GREYAssertEqual(evicted, 0, @"Check number of evicted tabs");
951 } 946 }
952 947
953 @end 948 @end
OLDNEW
« no previous file with comments | « ios/chrome/browser/context_menu/context_menu_egtest.mm ('k') | ios/chrome/browser/ui/history/history_ui_egtest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698