OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <vector> | 5 #include <vector> |
6 | 6 |
7 #include "chrome/browser/extensions/webstore_inline_installer.h" | 7 #include "chrome/browser/extensions/webstore_inline_installer.h" |
8 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 8 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
9 #include "content/public/browser/browser_thread.h" | |
10 #include "content/public/browser/web_contents.h" | 9 #include "content/public/browser/web_contents.h" |
11 #include "content/public/test/test_browser_thread.h" | |
12 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
13 #include "url/gurl.h" | 11 #include "url/gurl.h" |
14 | 12 |
15 namespace extensions { | 13 namespace extensions { |
16 | 14 |
17 namespace { | 15 namespace { |
18 | 16 |
19 // Wraps WebstoreInlineInstaller to provide access to domain verification | 17 // Wraps WebstoreInlineInstaller to provide access to domain verification |
20 // methods for testing. | 18 // methods for testing. |
21 class TestWebstoreInlineInstaller : public WebstoreInlineInstaller { | 19 class TestWebstoreInlineInstaller : public WebstoreInlineInstaller { |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 sites->Append(new base::StringValue(*it)); | 97 sites->Append(new base::StringValue(*it)); |
100 } | 98 } |
101 base::DictionaryValue webstore_data; | 99 base::DictionaryValue webstore_data; |
102 webstore_data.Set("verified_sites", sites); | 100 webstore_data.Set("verified_sites", sites); |
103 | 101 |
104 scoped_refptr<TestWebstoreInlineInstaller> installer = | 102 scoped_refptr<TestWebstoreInlineInstaller> installer = |
105 new TestWebstoreInlineInstaller(web_contents_.get(), requestor_url); | 103 new TestWebstoreInlineInstaller(web_contents_.get(), requestor_url); |
106 return installer->TestCheckRequestorPermitted(webstore_data); | 104 return installer->TestCheckRequestorPermitted(webstore_data); |
107 } | 105 } |
108 | 106 |
109 } // namespace | 107 } // namespace |
110 | 108 |
111 TEST_F(WebstoreInlineInstallerTest, DomainVerification) { | 109 TEST_F(WebstoreInlineInstallerTest, DomainVerification) { |
112 // Exact domain match. | 110 // Exact domain match. |
113 EXPECT_TRUE(TestSingleVerifiedSite("http://example.com", "example.com")); | 111 EXPECT_TRUE(TestSingleVerifiedSite("http://example.com", "example.com")); |
114 | 112 |
115 // The HTTPS scheme is allowed. | 113 // The HTTPS scheme is allowed. |
116 EXPECT_TRUE(TestSingleVerifiedSite("https://example.com", "example.com")); | 114 EXPECT_TRUE(TestSingleVerifiedSite("https://example.com", "example.com")); |
117 | 115 |
118 // The file: scheme is not allowed. | 116 // The file: scheme is not allowed. |
119 EXPECT_FALSE(TestSingleVerifiedSite("file:///example.com", "example.com")); | 117 EXPECT_FALSE(TestSingleVerifiedSite("file:///example.com", "example.com")); |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 verified_sites)); | 215 verified_sites)); |
218 | 216 |
219 EXPECT_FALSE(TestMultipleVerifiedSites("http://baz.example.com", | 217 EXPECT_FALSE(TestMultipleVerifiedSites("http://baz.example.com", |
220 verified_sites)); | 218 verified_sites)); |
221 | 219 |
222 EXPECT_FALSE(TestMultipleVerifiedSites("http://bar.example.com:456", | 220 EXPECT_FALSE(TestMultipleVerifiedSites("http://bar.example.com:456", |
223 verified_sites)); | 221 verified_sites)); |
224 } | 222 } |
225 | 223 |
226 } // namespace extensions | 224 } // namespace extensions |
OLD | NEW |