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

Side by Side Diff: ios/web/public/test/earl_grey/web_view_actions.mm

Issue 2642193012: Make EarlGrey matchers compliant with Chromium style. (Closed)
Patch Set: mistake Created 3 years, 11 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/web/public/test/earl_grey/web_view_actions.h" 5 #import "ios/web/public/test/earl_grey/web_view_actions.h"
6 6
7 #include "base/callback_helpers.h" 7 #include "base/callback_helpers.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #import "base/mac/bind_objc_block.h" 9 #import "base/mac/bind_objc_block.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 @"javascript for element_id %s", 159 @"javascript for element_id %s",
160 element_id.c_str()]; 160 element_id.c_str()];
161 NSDictionary* user_info = @{NSLocalizedDescriptionKey : description}; 161 NSDictionary* user_info = @{NSLocalizedDescriptionKey : description};
162 *error = [NSError errorWithDomain:kGREYInteractionErrorDomain 162 *error = [NSError errorWithDomain:kGREYInteractionErrorDomain
163 code:kGREYInteractionActionFailedErrorCode 163 code:kGREYInteractionActionFailedErrorCode
164 userInfo:user_info]; 164 userInfo:user_info];
165 return NO; 165 return NO;
166 } 166 }
167 167
168 // Run the action. 168 // Run the action.
169 [[EarlGrey selectElementWithMatcher:webViewInWebState(state)] 169 [[EarlGrey selectElementWithMatcher:WebViewInWebState(state)]
170 performAction:action 170 performAction:action
171 error:error]; 171 error:error];
172 172
173 if (*error) { 173 if (*error) {
174 return NO; 174 return NO;
175 } 175 }
176 176
177 // Wait for the verified to trigger and set |verified|. 177 // Wait for the verified to trigger and set |verified|.
178 NSString* verification_timeout_message = 178 NSString* verification_timeout_message =
179 [NSString stringWithFormat:@"The action (%@) on element_id %s wasn't " 179 [NSString stringWithFormat:@"The action (%@) on element_id %s wasn't "
180 @"verified before timing out.", 180 @"verified before timing out.",
181 action.name, element_id.c_str()]; 181 action.name, element_id.c_str()];
182 GREYAssert(testing::WaitUntilConditionOrTimeout( 182 GREYAssert(testing::WaitUntilConditionOrTimeout(
183 kWaitForVerificationTimeout, 183 kWaitForVerificationTimeout,
184 ^{ 184 ^{
185 return verified; 185 return verified;
186 }), 186 }),
187 verification_timeout_message); 187 verification_timeout_message);
188 188
189 // If |verified| is not true, the wait condition should have already exited 189 // If |verified| is not true, the wait condition should have already exited
190 // this control flow, so sanity check that it has in fact been set to 190 // this control flow, so sanity check that it has in fact been set to
191 // true by this point. 191 // true by this point.
192 DCHECK(verified); 192 DCHECK(verified);
193 return YES; 193 return YES;
194 }; 194 };
195 195
196 return [GREYActionBlock actionWithName:action_name 196 return [GREYActionBlock actionWithName:action_name
197 constraints:webViewInWebState(state) 197 constraints:WebViewInWebState(state)
198 performBlock:verified_tap]; 198 performBlock:verified_tap];
199 } 199 }
200 200
201 id<GREYAction> webViewLongPressElementForContextMenu( 201 id<GREYAction> webViewLongPressElementForContextMenu(
202 WebState* state, 202 WebState* state,
203 const std::string& element_id, 203 const std::string& element_id,
204 bool triggers_context_menu) { 204 bool triggers_context_menu) {
205 CGRect rect = web::test::GetBoundingRectOfElementWithId(state, element_id); 205 CGRect rect = web::test::GetBoundingRectOfElementWithId(state, element_id);
206 if (CGRectIsEmpty(rect)) { 206 if (CGRectIsEmpty(rect)) {
207 return webViewElementNotFound(element_id); 207 return webViewElementNotFound(element_id);
(...skipping 10 matching lines...) Expand all
218 id<GREYAction> webViewTapElement(WebState* state, 218 id<GREYAction> webViewTapElement(WebState* state,
219 const std::string& element_id) { 219 const std::string& element_id) {
220 CGRect rect = web::test::GetBoundingRectOfElementWithId(state, element_id); 220 CGRect rect = web::test::GetBoundingRectOfElementWithId(state, element_id);
221 CGPoint point = CGPointMake(CGRectGetMidX(rect), CGRectGetMidY(rect)); 221 CGPoint point = CGPointMake(CGRectGetMidX(rect), CGRectGetMidY(rect));
222 return CGRectIsEmpty(rect) ? webViewElementNotFound(element_id) 222 return CGRectIsEmpty(rect) ? webViewElementNotFound(element_id)
223 : webViewVerifiedActionOnElement( 223 : webViewVerifiedActionOnElement(
224 state, grey_tapAtPoint(point), element_id); 224 state, grey_tapAtPoint(point), element_id);
225 } 225 }
226 226
227 } // namespace web 227 } // namespace web
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698