OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 12 matching lines...) Expand all Loading... |
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #include "public/web/WebSearchableFormData.h" | 31 #include "public/web/WebSearchableFormData.h" |
32 | 32 |
| 33 #include <string> |
| 34 |
33 #include "core/frame/FrameTestHelpers.h" | 35 #include "core/frame/FrameTestHelpers.h" |
| 36 #include "core/frame/WebLocalFrameBase.h" |
34 #include "platform/testing/URLTestHelpers.h" | 37 #include "platform/testing/URLTestHelpers.h" |
35 #include "platform/testing/UnitTestHelpers.h" | 38 #include "platform/testing/UnitTestHelpers.h" |
36 #include "public/platform/Platform.h" | 39 #include "public/platform/Platform.h" |
37 #include "public/platform/WebURLLoaderMockFactory.h" | 40 #include "public/platform/WebURLLoaderMockFactory.h" |
38 #include "public/web/WebDocument.h" | 41 #include "public/web/WebDocument.h" |
39 #include "public/web/WebFrame.h" | 42 #include "public/web/WebFrame.h" |
| 43 #include "public/web/WebLocalFrame.h" |
40 #include "testing/gmock/include/gmock/gmock.h" | 44 #include "testing/gmock/include/gmock/gmock.h" |
41 #include "testing/gtest/include/gtest/gtest.h" | 45 #include "testing/gtest/include/gtest/gtest.h" |
42 | 46 |
43 namespace blink { | 47 namespace blink { |
44 | 48 |
45 namespace { | 49 namespace { |
46 | 50 |
47 void RegisterMockedURLLoadFromBaseURL(const std::string& base_url, | 51 void RegisterMockedURLLoadFromBaseURL(const std::string& base_url, |
48 const std::string& file_name) { | 52 const std::string& file_name) { |
49 URLTestHelpers::RegisterMockedURLLoadFromBase(WebString::FromUTF8(base_url), | 53 URLTestHelpers::RegisterMockedURLLoadFromBase(WebString::FromUTF8(base_url), |
(...skipping 11 matching lines...) Expand all Loading... |
61 ->UnregisterAllURLsAndClearMemoryCache(); | 65 ->UnregisterAllURLsAndClearMemoryCache(); |
62 } | 66 } |
63 | 67 |
64 FrameTestHelpers::WebViewHelper web_view_helper_; | 68 FrameTestHelpers::WebViewHelper web_view_helper_; |
65 }; | 69 }; |
66 | 70 |
67 } // namespace | 71 } // namespace |
68 TEST_F(WebSearchableFormDataTest, HttpSearchString) { | 72 TEST_F(WebSearchableFormDataTest, HttpSearchString) { |
69 std::string base_url("http://www.test.com/"); | 73 std::string base_url("http://www.test.com/"); |
70 RegisterMockedURLLoadFromBaseURL(base_url, "search_form_http.html"); | 74 RegisterMockedURLLoadFromBaseURL(base_url, "search_form_http.html"); |
71 WebView* web_view = | 75 WebViewBase* web_view = |
72 web_view_helper_.InitializeAndLoad(base_url + "search_form_http.html"); | 76 web_view_helper_.InitializeAndLoad(base_url + "search_form_http.html"); |
73 | 77 |
74 WebVector<WebFormElement> forms; | 78 WebVector<WebFormElement> forms; |
75 web_view->MainFrame()->GetDocument().Forms(forms); | 79 web_view->MainFrameImpl()->GetDocument().Forms(forms); |
76 | 80 |
77 EXPECT_EQ(forms.size(), 1U); | 81 EXPECT_EQ(forms.size(), 1U); |
78 | 82 |
79 WebSearchableFormData searchable_form_data(forms[0]); | 83 WebSearchableFormData searchable_form_data(forms[0]); |
80 EXPECT_EQ("http://www.mock.url/search?hl=en&q={searchTerms}&btnM=Mock+Search", | 84 EXPECT_EQ("http://www.mock.url/search?hl=en&q={searchTerms}&btnM=Mock+Search", |
81 searchable_form_data.Url().GetString()); | 85 searchable_form_data.Url().GetString()); |
82 } | 86 } |
83 | 87 |
84 TEST_F(WebSearchableFormDataTest, HttpsSearchString) { | 88 TEST_F(WebSearchableFormDataTest, HttpsSearchString) { |
85 std::string base_url("https://www.test.com/"); | 89 std::string base_url("https://www.test.com/"); |
86 RegisterMockedURLLoadFromBaseURL(base_url, "search_form_https.html"); | 90 RegisterMockedURLLoadFromBaseURL(base_url, "search_form_https.html"); |
87 WebView* web_view = | 91 WebViewBase* web_view = |
88 web_view_helper_.InitializeAndLoad(base_url + "search_form_https.html"); | 92 web_view_helper_.InitializeAndLoad(base_url + "search_form_https.html"); |
89 | 93 |
90 WebVector<WebFormElement> forms; | 94 WebVector<WebFormElement> forms; |
91 web_view->MainFrame()->GetDocument().Forms(forms); | 95 web_view->MainFrameImpl()->GetDocument().Forms(forms); |
92 | 96 |
93 EXPECT_EQ(forms.size(), 1U); | 97 EXPECT_EQ(forms.size(), 1U); |
94 | 98 |
95 WebSearchableFormData searchable_form_data(forms[0]); | 99 WebSearchableFormData searchable_form_data(forms[0]); |
96 EXPECT_EQ( | 100 EXPECT_EQ( |
97 "https://www.mock.url/search?hl=en&q={searchTerms}&btnM=Mock+Search", | 101 "https://www.mock.url/search?hl=en&q={searchTerms}&btnM=Mock+Search", |
98 searchable_form_data.Url().GetString()); | 102 searchable_form_data.Url().GetString()); |
99 } | 103 } |
100 | 104 |
101 } // namespace blink | 105 } // namespace blink |
OLD | NEW |