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 <set> | 5 #include <set> |
6 #include <string> | 6 #include <string> |
7 | 7 |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 } | 78 } |
79 | 79 |
80 bool OnExternalExtensionUpdateUrlFound( | 80 bool OnExternalExtensionUpdateUrlFound( |
81 const extensions::ExternalInstallInfoUpdateUrl& info, | 81 const extensions::ExternalInstallInfoUpdateUrl& info, |
82 bool is_initial_load) override { | 82 bool is_initial_load) override { |
83 // Extension has the correct location. | 83 // Extension has the correct location. |
84 EXPECT_EQ(Manifest::EXTERNAL_POLICY_DOWNLOAD, info.download_location); | 84 EXPECT_EQ(Manifest::EXTERNAL_POLICY_DOWNLOAD, info.download_location); |
85 | 85 |
86 // Provider returns the correct location when asked. | 86 // Provider returns the correct location when asked. |
87 Manifest::Location location1; | 87 Manifest::Location location1; |
88 scoped_ptr<Version> version1; | 88 std::unique_ptr<Version> version1; |
89 provider_->GetExtensionDetails(info.extension_id, &location1, &version1); | 89 provider_->GetExtensionDetails(info.extension_id, &location1, &version1); |
90 EXPECT_EQ(Manifest::EXTERNAL_POLICY_DOWNLOAD, location1); | 90 EXPECT_EQ(Manifest::EXTERNAL_POLICY_DOWNLOAD, location1); |
91 EXPECT_FALSE(version1.get()); | 91 EXPECT_FALSE(version1.get()); |
92 | 92 |
93 // Remove the extension from our list. | 93 // Remove the extension from our list. |
94 EXPECT_EQ(1U, expected_extensions_.erase(info.extension_id)); | 94 EXPECT_EQ(1U, expected_extensions_.erase(info.extension_id)); |
95 return true; | 95 return true; |
96 } | 96 } |
97 | 97 |
98 void OnExternalProviderReady( | 98 void OnExternalProviderReady( |
99 const ExternalProviderInterface* provider) override { | 99 const ExternalProviderInterface* provider) override { |
100 EXPECT_EQ(provider, provider_.get()); | 100 EXPECT_EQ(provider, provider_.get()); |
101 EXPECT_TRUE(provider->IsReady()); | 101 EXPECT_TRUE(provider->IsReady()); |
102 } | 102 } |
103 | 103 |
104 void OnExternalProviderUpdateComplete( | 104 void OnExternalProviderUpdateComplete( |
105 const ExternalProviderInterface* provider, | 105 const ExternalProviderInterface* provider, |
106 const ScopedVector<ExternalInstallInfoUpdateUrl>& update_url_extensions, | 106 const ScopedVector<ExternalInstallInfoUpdateUrl>& update_url_extensions, |
107 const ScopedVector<ExternalInstallInfoFile>& file_extensions, | 107 const ScopedVector<ExternalInstallInfoFile>& file_extensions, |
108 const std::set<std::string>& removed_extensions) override { | 108 const std::set<std::string>& removed_extensions) override { |
109 ADD_FAILURE() << "Only win registry provider is expected to call this."; | 109 ADD_FAILURE() << "Only win registry provider is expected to call this."; |
110 } | 110 } |
111 | 111 |
112 private: | 112 private: |
113 std::set<std::string> expected_extensions_; | 113 std::set<std::string> expected_extensions_; |
114 | 114 |
115 scoped_ptr<TestingProfile> profile_; | 115 std::unique_ptr<TestingProfile> profile_; |
116 | 116 |
117 scoped_ptr<ExternalProviderImpl> provider_; | 117 std::unique_ptr<ExternalProviderImpl> provider_; |
118 | 118 |
119 DISALLOW_COPY_AND_ASSIGN(MockExternalPolicyProviderVisitor); | 119 DISALLOW_COPY_AND_ASSIGN(MockExternalPolicyProviderVisitor); |
120 }; | 120 }; |
121 | 121 |
122 TEST_F(ExternalPolicyLoaderTest, PolicyIsParsed) { | 122 TEST_F(ExternalPolicyLoaderTest, PolicyIsParsed) { |
123 base::DictionaryValue forced_extensions; | 123 base::DictionaryValue forced_extensions; |
124 std::set<std::string> expected_extensions; | 124 std::set<std::string> expected_extensions; |
125 extensions::ExternalPolicyLoader::AddExtension( | 125 extensions::ExternalPolicyLoader::AddExtension( |
126 &forced_extensions, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", | 126 &forced_extensions, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", |
127 "http://www.example.com/crx?a=5;b=6"); | 127 "http://www.example.com/crx?a=5;b=6"); |
(...skipping 20 matching lines...) Expand all Loading... |
148 forced_extensions.SetString("invalid", "http://www.example.com/crx"); | 148 forced_extensions.SetString("invalid", "http://www.example.com/crx"); |
149 forced_extensions.SetString("dddddddddddddddddddddddddddddddd", | 149 forced_extensions.SetString("dddddddddddddddddddddddddddddddd", |
150 std::string()); | 150 std::string()); |
151 forced_extensions.SetString("invalid", "bad"); | 151 forced_extensions.SetString("invalid", "bad"); |
152 | 152 |
153 MockExternalPolicyProviderVisitor mv; | 153 MockExternalPolicyProviderVisitor mv; |
154 mv.Visit(forced_extensions, expected_extensions); | 154 mv.Visit(forced_extensions, expected_extensions); |
155 } | 155 } |
156 | 156 |
157 } // namespace extensions | 157 } // namespace extensions |
OLD | NEW |