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

Side by Side Diff: third_party/WebKit/Source/web/tests/WebSearchableFormDataTest.cpp

Issue 2505933005: Auto-Generating Search Engines - Remove HTTP Restriction (Closed)
Patch Set: added test 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 unified diff | Download patch
OLDNEW
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 26 matching lines...) Expand all
37 #include "public/web/WebDocument.h" 37 #include "public/web/WebDocument.h"
38 #include "public/web/WebFrame.h" 38 #include "public/web/WebFrame.h"
39 #include "testing/gmock/include/gmock/gmock.h" 39 #include "testing/gmock/include/gmock/gmock.h"
40 #include "testing/gtest/include/gtest/gtest.h" 40 #include "testing/gtest/include/gtest/gtest.h"
41 #include "web/tests/FrameTestHelpers.h" 41 #include "web/tests/FrameTestHelpers.h"
42 42
43 namespace blink { 43 namespace blink {
44 44
45 class WebSearchableFormDataTest : public testing::Test { 45 class WebSearchableFormDataTest : public testing::Test {
46 protected: 46 protected:
47 WebSearchableFormDataTest() : m_baseURL("http://www.test.com/") {} 47 WebSearchableFormDataTest() {}
48 48
49 ~WebSearchableFormDataTest() override { 49 ~WebSearchableFormDataTest() override {
50 Platform::current()->getURLLoaderMockFactory()->unregisterAllURLs(); 50 Platform::current()->getURLLoaderMockFactory()->unregisterAllURLs();
51 WebCache::clear(); 51 WebCache::clear();
52 } 52 }
53 53
54 FrameTestHelpers::WebViewHelper m_webViewHelper; 54 FrameTestHelpers::WebViewHelper m_webViewHelper;
55 std::string m_baseURL;
56 }; 55 };
57 56
58 TEST_F(WebSearchableFormDataTest, SearchString) { 57 TEST_F(WebSearchableFormDataTest, HttpSearchString) {
58 std::string baseURL("http://www.test.com/");
59 URLTestHelpers::registerMockedURLFromBaseURL( 59 URLTestHelpers::registerMockedURLFromBaseURL(
60 WebString::fromUTF8(m_baseURL.c_str()), "search_form.html"); 60 WebString::fromUTF8(baseURL.c_str()), "search_form_http.html");
61 WebView* webView = 61 WebView* webView =
62 m_webViewHelper.initializeAndLoad(m_baseURL + "search_form.html"); 62 m_webViewHelper.initializeAndLoad(baseURL + "search_form_http.html");
63 63
64 WebVector<WebFormElement> forms; 64 WebVector<WebFormElement> forms;
65 webView->mainFrame()->document().forms(forms); 65 webView->mainFrame()->document().forms(forms);
66 66
67 EXPECT_EQ(forms.size(), 1U); 67 EXPECT_EQ(forms.size(), 1U);
68 68
69 WebSearchableFormData searchableFormData(forms[0]); 69 WebSearchableFormData searchableFormData(forms[0]);
70 EXPECT_EQ("http://www.mock.url/search?hl=en&q={searchTerms}&btnM=Mock+Search", 70 EXPECT_EQ("http://www.mock.url/search?hl=en&q={searchTerms}&btnM=Mock+Search",
71 searchableFormData.url().string()); 71 searchableFormData.url().string());
72 } 72 }
73 73
74 TEST_F(WebSearchableFormDataTest, HttpsSearchString) {
75 std::string baseURL("https://www.test.com/");
76 URLTestHelpers::registerMockedURLFromBaseURL(
77 WebString::fromUTF8(baseURL.c_str()), "search_form_https.html");
78 WebView* webView =
79 m_webViewHelper.initializeAndLoad(baseURL + "search_form_https.html");
80
81 WebVector<WebFormElement> forms;
82 webView->mainFrame()->document().forms(forms);
83
84 EXPECT_EQ(forms.size(), 1U);
85
86 WebSearchableFormData searchableFormData(forms[0]);
87 EXPECT_EQ(
88 "https://www.mock.url/search?hl=en&q={searchTerms}&btnM=Mock+Search",
89 searchableFormData.url().string());
90 }
91
74 } // namespace blink 92 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/WebSearchableFormData.cpp ('k') | third_party/WebKit/Source/web/tests/data/search_form.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698