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

Unified Diff: ios/chrome/test/earl_grey/chrome_actions.mm

Issue 2580333003: Upstream Chrome on iOS source code [10/11]. (Closed)
Patch Set: Created 4 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ios/chrome/test/earl_grey/chrome_actions.h ('k') | ios/chrome/test/earl_grey/chrome_assertions.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/test/earl_grey/chrome_actions.mm
diff --git a/ios/chrome/test/earl_grey/chrome_actions.mm b/ios/chrome/test/earl_grey/chrome_actions.mm
new file mode 100644
index 0000000000000000000000000000000000000000..d893a86555c794cddc40011f54ada84e8a33e904
--- /dev/null
+++ b/ios/chrome/test/earl_grey/chrome_actions.mm
@@ -0,0 +1,44 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#import "ios/chrome/test/earl_grey/chrome_actions.h"
+
+#import "base/mac/foundation_util.h"
+#import "ios/chrome/browser/ui/collection_view/cells/collection_view_switch_item.h"
+#import "ios/chrome/test/app/chrome_test_util.h"
+#import "ios/web/public/test/earl_grey/web_view_actions.h"
+
+namespace chrome_test_util {
+
+id<GREYAction> longPressElementForContextMenu(const std::string& element_id,
+ bool triggers_context_menu) {
+ return webViewLongPressElementForContextMenu(
+ chrome_test_util::GetCurrentWebState(), element_id,
+ triggers_context_menu);
+}
+
+id<GREYAction> turnCollectionViewSwitchOn(BOOL on) {
+ id<GREYMatcher> constraints = grey_not(grey_systemAlertViewShown());
+ NSString* actionName =
+ [NSString stringWithFormat:@"Turn collection view switch to %@ state",
+ on ? @"ON" : @"OFF"];
+ return [GREYActionBlock
+ actionWithName:actionName
+ constraints:constraints
+ performBlock:^BOOL(id collectionViewCell,
+ __strong NSError** errorOrNil) {
+ CollectionViewSwitchCell* switchCell =
+ base::mac::ObjCCastStrict<CollectionViewSwitchCell>(
+ collectionViewCell);
+ UISwitch* switchView = switchCell.switchView;
+ if (switchView.on ^ on) {
+ id<GREYAction> longPressAction = [GREYActions
+ actionForLongPressWithDuration:kGREYLongPressDefaultDuration];
+ return [longPressAction perform:switchView error:errorOrNil];
+ }
+ return YES;
+ }];
+}
+
+} // namespace chrome_test_util
« no previous file with comments | « ios/chrome/test/earl_grey/chrome_actions.h ('k') | ios/chrome/test/earl_grey/chrome_assertions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698