OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/bind_helpers.h" | 6 #include "base/bind_helpers.h" |
7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 crx_update_item.id = "jebgalgnebhfojomionfpkfelancnnkf"; | 159 crx_update_item.id = "jebgalgnebhfojomionfpkfelancnnkf"; |
160 crx_update_item.component = crx_component; | 160 crx_update_item.component = crx_component; |
161 | 161 |
162 return crx_update_item; | 162 return crx_update_item; |
163 } | 163 } |
164 | 164 |
165 TEST_F(UpdateCheckerTest, UpdateCheckSuccess) { | 165 TEST_F(UpdateCheckerTest, UpdateCheckSuccess) { |
166 EXPECT_TRUE(post_interceptor_->ExpectRequest( | 166 EXPECT_TRUE(post_interceptor_->ExpectRequest( |
167 new PartialMatch("updatecheck"), test_file("updatecheck_reply_1.xml"))); | 167 new PartialMatch("updatecheck"), test_file("updatecheck_reply_1.xml"))); |
168 | 168 |
169 update_checker_ = UpdateChecker::Create(*config_).Pass(); | 169 update_checker_ = UpdateChecker::Create(*config_); |
170 | 170 |
171 CrxUpdateItem item(BuildCrxUpdateItem()); | 171 CrxUpdateItem item(BuildCrxUpdateItem()); |
172 std::vector<CrxUpdateItem*> items_to_check; | 172 std::vector<CrxUpdateItem*> items_to_check; |
173 items_to_check.push_back(&item); | 173 items_to_check.push_back(&item); |
174 | 174 |
175 update_checker_->CheckForUpdates( | 175 update_checker_->CheckForUpdates( |
176 items_to_check, "extra=\"params\"", | 176 items_to_check, "extra=\"params\"", |
177 base::Bind(&UpdateCheckerTest::UpdateCheckComplete, | 177 base::Bind(&UpdateCheckerTest::UpdateCheckComplete, |
178 base::Unretained(this))); | 178 base::Unretained(this))); |
179 | 179 |
(...skipping 25 matching lines...) Expand all Loading... |
205 EXPECT_STREQ("jebgalgnebhfojomionfpkfelancnnkf", | 205 EXPECT_STREQ("jebgalgnebhfojomionfpkfelancnnkf", |
206 results_.list[0].extension_id.c_str()); | 206 results_.list[0].extension_id.c_str()); |
207 EXPECT_STREQ("1.0", results_.list[0].manifest.version.c_str()); | 207 EXPECT_STREQ("1.0", results_.list[0].manifest.version.c_str()); |
208 } | 208 } |
209 | 209 |
210 // Simulates a 403 server response error. | 210 // Simulates a 403 server response error. |
211 TEST_F(UpdateCheckerTest, UpdateCheckError) { | 211 TEST_F(UpdateCheckerTest, UpdateCheckError) { |
212 EXPECT_TRUE( | 212 EXPECT_TRUE( |
213 post_interceptor_->ExpectRequest(new PartialMatch("updatecheck"), 403)); | 213 post_interceptor_->ExpectRequest(new PartialMatch("updatecheck"), 403)); |
214 | 214 |
215 update_checker_ = UpdateChecker::Create(*config_).Pass(); | 215 update_checker_ = UpdateChecker::Create(*config_); |
216 | 216 |
217 CrxUpdateItem item(BuildCrxUpdateItem()); | 217 CrxUpdateItem item(BuildCrxUpdateItem()); |
218 std::vector<CrxUpdateItem*> items_to_check; | 218 std::vector<CrxUpdateItem*> items_to_check; |
219 items_to_check.push_back(&item); | 219 items_to_check.push_back(&item); |
220 | 220 |
221 update_checker_->CheckForUpdates( | 221 update_checker_->CheckForUpdates( |
222 items_to_check, "", base::Bind(&UpdateCheckerTest::UpdateCheckComplete, | 222 items_to_check, "", base::Bind(&UpdateCheckerTest::UpdateCheckComplete, |
223 base::Unretained(this))); | 223 base::Unretained(this))); |
224 | 224 |
225 RunThreads(); | 225 RunThreads(); |
226 | 226 |
227 EXPECT_EQ(1, post_interceptor_->GetHitCount()) | 227 EXPECT_EQ(1, post_interceptor_->GetHitCount()) |
228 << post_interceptor_->GetRequestsAsString(); | 228 << post_interceptor_->GetRequestsAsString(); |
229 EXPECT_EQ(1, post_interceptor_->GetCount()) | 229 EXPECT_EQ(1, post_interceptor_->GetCount()) |
230 << post_interceptor_->GetRequestsAsString(); | 230 << post_interceptor_->GetRequestsAsString(); |
231 | 231 |
232 ASSERT_FALSE(config_->UpdateUrl().empty()); | 232 ASSERT_FALSE(config_->UpdateUrl().empty()); |
233 EXPECT_EQ(config_->UpdateUrl().front(), original_url_); | 233 EXPECT_EQ(config_->UpdateUrl().front(), original_url_); |
234 EXPECT_EQ(403, error_); | 234 EXPECT_EQ(403, error_); |
235 EXPECT_STREQ("network error", error_message_.c_str()); | 235 EXPECT_STREQ("network error", error_message_.c_str()); |
236 EXPECT_EQ(0ul, results_.list.size()); | 236 EXPECT_EQ(0ul, results_.list.size()); |
237 } | 237 } |
238 | 238 |
239 } // namespace update_client | 239 } // namespace update_client |
OLD | NEW |