| 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 | 6 |
| 7 #include "base/strings/sys_string_conversions.h" | 7 #include "base/strings/sys_string_conversions.h" |
| 8 #import "base/test/ios/wait_util.h" | 8 #import "base/test/ios/wait_util.h" |
| 9 #include "ios/chrome/browser/autofill/form_input_accessory_view_controller.h" | 9 #include "ios/chrome/browser/autofill/form_input_accessory_view_controller.h" |
| 10 #include "ios/chrome/browser/ui/ui_util.h" | 10 #include "ios/chrome/browser/ui/ui_util.h" |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 if (IsIPadIdiom()) { | 78 if (IsIPadIdiom()) { |
| 79 EARL_GREY_TEST_SKIPPED(@"Skipped for iPad (no hidden toolbar in tablet)"); | 79 EARL_GREY_TEST_SKIPPED(@"Skipped for iPad (no hidden toolbar in tablet)"); |
| 80 } | 80 } |
| 81 | 81 |
| 82 web::test::SetUpFileBasedHttpServer(); | 82 web::test::SetUpFileBasedHttpServer(); |
| 83 GURL URL = web::test::HttpServer::MakeUrl( | 83 GURL URL = web::test::HttpServer::MakeUrl( |
| 84 "http://ios/testing/data/http_server_files/multi_field_form.html"); | 84 "http://ios/testing/data/http_server_files/multi_field_form.html"); |
| 85 [ChromeEarlGrey loadURL:URL]; | 85 [ChromeEarlGrey loadURL:URL]; |
| 86 | 86 |
| 87 id<GREYMatcher> webViewMatcher = | 87 id<GREYMatcher> webViewMatcher = |
| 88 chrome_test_util::webViewContainingText("hello!"); | 88 chrome_test_util::WebViewContainingText("hello!"); |
| 89 [[EarlGrey selectElementWithMatcher:webViewMatcher] | 89 [[EarlGrey selectElementWithMatcher:webViewMatcher] |
| 90 assertWithMatcher:grey_notNil()]; | 90 assertWithMatcher:grey_notNil()]; |
| 91 | 91 |
| 92 // Opening the keyboard from a webview blocks EarlGrey's synchronization. | 92 // Opening the keyboard from a webview blocks EarlGrey's synchronization. |
| 93 [[GREYConfiguration sharedInstance] | 93 [[GREYConfiguration sharedInstance] |
| 94 setValue:@NO | 94 setValue:@NO |
| 95 forConfigKey:kGREYConfigKeySynchronizationEnabled]; | 95 forConfigKey:kGREYConfigKeySynchronizationEnabled]; |
| 96 | 96 |
| 97 // Brings up the keyboard by tapping on one of the form's field. | 97 // Brings up the keyboard by tapping on one of the form's field. |
| 98 [[EarlGrey | 98 [[EarlGrey |
| 99 selectElementWithMatcher:web::webViewInWebState( | 99 selectElementWithMatcher:web::WebViewInWebState( |
| 100 chrome_test_util::GetCurrentWebState())] | 100 chrome_test_util::GetCurrentWebState())] |
| 101 performAction:web::webViewTapElement( | 101 performAction:web::webViewTapElement( |
| 102 chrome_test_util::GetCurrentWebState(), | 102 chrome_test_util::GetCurrentWebState(), |
| 103 kFormElementId1)]; | 103 kFormElementId1)]; |
| 104 | 104 |
| 105 id<GREYMatcher> nextButtonMatcher = | 105 id<GREYMatcher> nextButtonMatcher = |
| 106 chrome_test_util::buttonWithAccessibilityLabelId( | 106 chrome_test_util::ButtonWithAccessibilityLabelId( |
| 107 IDS_IOS_AUTOFILL_ACCNAME_NEXT_FIELD); | 107 IDS_IOS_AUTOFILL_ACCNAME_NEXT_FIELD); |
| 108 id<GREYMatcher> previousButtonMatcher = | 108 id<GREYMatcher> previousButtonMatcher = |
| 109 chrome_test_util::buttonWithAccessibilityLabelId( | 109 chrome_test_util::ButtonWithAccessibilityLabelId( |
| 110 IDS_IOS_AUTOFILL_ACCNAME_PREVIOUS_FIELD); | 110 IDS_IOS_AUTOFILL_ACCNAME_PREVIOUS_FIELD); |
| 111 id<GREYMatcher> closeButtonMatcher = | 111 id<GREYMatcher> closeButtonMatcher = |
| 112 chrome_test_util::buttonWithAccessibilityLabelId( | 112 chrome_test_util::ButtonWithAccessibilityLabelId( |
| 113 IDS_IOS_AUTOFILL_ACCNAME_HIDE_KEYBOARD); | 113 IDS_IOS_AUTOFILL_ACCNAME_HIDE_KEYBOARD); |
| 114 | 114 |
| 115 // Wait until the keyboard's "Next" button appeared. | 115 // Wait until the keyboard's "Next" button appeared. |
| 116 NSString* description = @"Wait for the keyboard's \"Next\" button to appear."; | 116 NSString* description = @"Wait for the keyboard's \"Next\" button to appear."; |
| 117 ConditionBlock condition = ^{ | 117 ConditionBlock condition = ^{ |
| 118 NSError* error = nil; | 118 NSError* error = nil; |
| 119 [[EarlGrey selectElementWithMatcher:nextButtonMatcher] | 119 [[EarlGrey selectElementWithMatcher:nextButtonMatcher] |
| 120 assertWithMatcher:grey_notNil() | 120 assertWithMatcher:grey_notNil() |
| 121 error:&error]; | 121 error:&error]; |
| 122 return (error == nil); | 122 return (error == nil); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 152 // visible doesn't crash the browser. | 152 // visible doesn't crash the browser. |
| 153 - (void)testCloseKeyboardWhenNotVisible { | 153 - (void)testCloseKeyboardWhenNotVisible { |
| 154 FormInputAccessoryViewController* inputAccessoryViewController = | 154 FormInputAccessoryViewController* inputAccessoryViewController = |
| 155 chrome_test_util::GetInputAccessoryViewController(); | 155 chrome_test_util::GetInputAccessoryViewController(); |
| 156 GREYAssertNotNil(inputAccessoryViewController, | 156 GREYAssertNotNil(inputAccessoryViewController, |
| 157 @"The tab's input accessory view should not be non nil."); | 157 @"The tab's input accessory view should not be non nil."); |
| 158 [inputAccessoryViewController closeKeyboardWithoutButtonPress]; | 158 [inputAccessoryViewController closeKeyboardWithoutButtonPress]; |
| 159 } | 159 } |
| 160 | 160 |
| 161 @end | 161 @end |
| OLD | NEW |