| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #include <stddef.h> | 5 #include <stddef.h> |
| 6 #include <Foundation/Foundation.h> | 6 #include <Foundation/Foundation.h> |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #import "ios/web/test/web_test.h" | 9 #import "ios/web/public/test/web_test_with_web_state.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 #include "testing/gtest_mac.h" | 11 #include "testing/gtest_mac.h" |
| 12 | 12 |
| 13 namespace { | 13 namespace { |
| 14 | 14 |
| 15 // Struct for isTextField() test data. | 15 // Struct for isTextField() test data. |
| 16 struct TextFieldTestElement { | 16 struct TextFieldTestElement { |
| 17 // The element name. | 17 // The element name. |
| 18 const char* element_name; | 18 const char* element_name; |
| 19 // The index of this element in those that have the same name. | 19 // The index of this element in those that have the same name. |
| 20 const int element_index; | 20 const int element_index; |
| 21 // True if this is expected to be a text field. | 21 // True if this is expected to be a text field. |
| 22 const bool expected_is_text_field; | 22 const bool expected_is_text_field; |
| 23 }; | 23 }; |
| 24 | 24 |
| 25 } // namespace | 25 } // namespace |
| 26 | 26 |
| 27 namespace web { | 27 namespace web { |
| 28 | 28 |
| 29 // Test fixture to test common.js. | 29 // Test fixture to test common.js. |
| 30 typedef web::WebTestWithWebController CommonJsTest; | 30 typedef web::WebTestWithWebState CommonJsTest; |
| 31 | 31 |
| 32 // Tests __gCrWeb.common.isTextField JavaScript API. | 32 // Tests __gCrWeb.common.isTextField JavaScript API. |
| 33 TEST_F(CommonJsTest, IsTestField) { | 33 TEST_F(CommonJsTest, IsTestField) { |
| 34 LoadHtml(@"<html><body>" | 34 LoadHtml(@"<html><body>" |
| 35 "<input type='text' name='firstname'>" | 35 "<input type='text' name='firstname'>" |
| 36 "<input type='text' name='lastname'>" | 36 "<input type='text' name='lastname'>" |
| 37 "<input type='email' name='email'>" | 37 "<input type='email' name='email'>" |
| 38 "<input type='tel' name='phone'>" | 38 "<input type='tel' name='phone'>" |
| 39 "<input type='url' name='blog'>" | 39 "<input type='url' name='blog'>" |
| 40 "<input type='number' name='expected number of clicks'>" | 40 "<input type='number' name='expected number of clicks'>" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 stringWithFormat:@"__gCrWeb.common.isTextField(" | 81 stringWithFormat:@"__gCrWeb.common.isTextField(" |
| 82 "window.document.getElementsByName('%s')[%d])", | 82 "window.document.getElementsByName('%s')[%d])", |
| 83 element.element_name, element.element_index]); | 83 element.element_name, element.element_index]); |
| 84 EXPECT_NSEQ(element.expected_is_text_field ? @"true" : @"false", result) | 84 EXPECT_NSEQ(element.expected_is_text_field ? @"true" : @"false", result) |
| 85 << element.element_name << " with index " << element.element_index | 85 << element.element_name << " with index " << element.element_index |
| 86 << " isTextField(): " << element.expected_is_text_field; | 86 << " isTextField(): " << element.expected_is_text_field; |
| 87 } | 87 } |
| 88 } | 88 } |
| 89 | 89 |
| 90 } // namespace web | 90 } // namespace web |
| OLD | NEW |