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

Side by Side Diff: ios/chrome/test/earl_grey/chrome_actions.mm

Issue 2777463002: Make custom GREYAction methods Chromium C-Style. (Closed)
Patch Set: more c-style 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 "ios/chrome/test/earl_grey/chrome_actions.h" 5 #import "ios/chrome/test/earl_grey/chrome_actions.h"
6 6
7 #import "base/mac/foundation_util.h" 7 #import "base/mac/foundation_util.h"
8 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_switch_item .h" 8 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_switch_item .h"
9 #import "ios/chrome/test/app/chrome_test_util.h" 9 #import "ios/chrome/test/app/chrome_test_util.h"
10 #import "ios/web/public/test/earl_grey/web_view_actions.h" 10 #import "ios/web/public/test/earl_grey/web_view_actions.h"
11 11
12 #if !defined(__has_feature) || !__has_feature(objc_arc) 12 #if !defined(__has_feature) || !__has_feature(objc_arc)
13 #error "This file requires ARC support." 13 #error "This file requires ARC support."
14 #endif 14 #endif
15 15
16 namespace chrome_test_util { 16 namespace chrome_test_util {
17 17
18 id<GREYAction> longPressElementForContextMenu(const std::string& element_id, 18 id<GREYAction> LongPressElementForContextMenu(const std::string& element_id,
19 bool triggers_context_menu) { 19 bool triggers_context_menu) {
20 return webViewLongPressElementForContextMenu( 20 return WebViewLongPressElementForContextMenu(
21 chrome_test_util::GetCurrentWebState(), element_id, 21 chrome_test_util::GetCurrentWebState(), element_id,
22 triggers_context_menu); 22 triggers_context_menu);
23 } 23 }
24 24
25 id<GREYAction> turnCollectionViewSwitchOn(BOOL on) { 25 id<GREYAction> longPressElementForContextMenu(const std::string& element_id,
26 bool triggers_context_menu) {
27 return LongPressElementForContextMenu(element_id, triggers_context_menu);
28 }
29
30 id<GREYAction> TurnCollectionViewSwitchOn(BOOL on) {
26 id<GREYMatcher> constraints = grey_not(grey_systemAlertViewShown()); 31 id<GREYMatcher> constraints = grey_not(grey_systemAlertViewShown());
27 NSString* actionName = 32 NSString* actionName =
28 [NSString stringWithFormat:@"Turn collection view switch to %@ state", 33 [NSString stringWithFormat:@"Turn collection view switch to %@ state",
29 on ? @"ON" : @"OFF"]; 34 on ? @"ON" : @"OFF"];
30 return [GREYActionBlock 35 return [GREYActionBlock
31 actionWithName:actionName 36 actionWithName:actionName
32 constraints:constraints 37 constraints:constraints
33 performBlock:^BOOL(id collectionViewCell, 38 performBlock:^BOOL(id collectionViewCell,
34 __strong NSError** errorOrNil) { 39 __strong NSError** errorOrNil) {
35 CollectionViewSwitchCell* switchCell = 40 CollectionViewSwitchCell* switchCell =
36 base::mac::ObjCCastStrict<CollectionViewSwitchCell>( 41 base::mac::ObjCCastStrict<CollectionViewSwitchCell>(
37 collectionViewCell); 42 collectionViewCell);
38 UISwitch* switchView = switchCell.switchView; 43 UISwitch* switchView = switchCell.switchView;
39 if (switchView.on ^ on) { 44 if (switchView.on ^ on) {
40 id<GREYAction> longPressAction = [GREYActions 45 id<GREYAction> longPressAction = [GREYActions
41 actionForLongPressWithDuration:kGREYLongPressDefaultDuration]; 46 actionForLongPressWithDuration:kGREYLongPressDefaultDuration];
42 return [longPressAction perform:switchView error:errorOrNil]; 47 return [longPressAction perform:switchView error:errorOrNil];
43 } 48 }
44 return YES; 49 return YES;
45 }]; 50 }];
46 } 51 }
47 52
48 } // namespace chrome_test_util 53 } // namespace chrome_test_util
OLDNEW
« no previous file with comments | « ios/chrome/test/earl_grey/chrome_actions.h ('k') | ios/web/public/test/earl_grey/web_view_actions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698