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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 RunThreads(); | 180 RunThreads(); |
181 | 181 |
182 EXPECT_EQ(1, post_interceptor_->GetHitCount()) | 182 EXPECT_EQ(1, post_interceptor_->GetHitCount()) |
183 << post_interceptor_->GetRequestsAsString(); | 183 << post_interceptor_->GetRequestsAsString(); |
184 ASSERT_EQ(1, post_interceptor_->GetCount()) | 184 ASSERT_EQ(1, post_interceptor_->GetCount()) |
185 << post_interceptor_->GetRequestsAsString(); | 185 << post_interceptor_->GetRequestsAsString(); |
186 | 186 |
187 // Sanity check the request. | 187 // Sanity check the request. |
188 EXPECT_NE(string::npos, post_interceptor_->GetRequests()[0].find( | 188 EXPECT_NE(string::npos, post_interceptor_->GetRequests()[0].find( |
189 "request protocol=\"3.0\" extra=\"params\"")); | 189 "request protocol=\"3.0\" extra=\"params\"")); |
| 190 // The request must not contain any "dlpref" in the default case. |
| 191 EXPECT_EQ(string::npos, |
| 192 post_interceptor_->GetRequests()[0].find(" dlpref=\"")); |
190 EXPECT_NE( | 193 EXPECT_NE( |
191 string::npos, | 194 string::npos, |
192 post_interceptor_->GetRequests()[0].find( | 195 post_interceptor_->GetRequests()[0].find( |
193 "app appid=\"jebgalgnebhfojomionfpkfelancnnkf\" version=\"0.9\">" | 196 "app appid=\"jebgalgnebhfojomionfpkfelancnnkf\" version=\"0.9\">" |
194 "<updatecheck /><packages><package fp=\"fp1\"/></packages></app>")); | 197 "<updatecheck /><packages><package fp=\"fp1\"/></packages></app>")); |
195 | 198 |
196 EXPECT_NE(string::npos, | 199 EXPECT_NE(string::npos, |
197 post_interceptor_->GetRequests()[0].find("<hw physmemory=")); | 200 post_interceptor_->GetRequests()[0].find("<hw physmemory=")); |
198 | 201 |
199 // Sanity check the arguments of the callback after parsing. | 202 // Sanity check the arguments of the callback after parsing. |
(...skipping 29 matching lines...) Expand all Loading... |
229 EXPECT_EQ(1, post_interceptor_->GetCount()) | 232 EXPECT_EQ(1, post_interceptor_->GetCount()) |
230 << post_interceptor_->GetRequestsAsString(); | 233 << post_interceptor_->GetRequestsAsString(); |
231 | 234 |
232 ASSERT_FALSE(config_->UpdateUrl().empty()); | 235 ASSERT_FALSE(config_->UpdateUrl().empty()); |
233 EXPECT_EQ(config_->UpdateUrl().front(), original_url_); | 236 EXPECT_EQ(config_->UpdateUrl().front(), original_url_); |
234 EXPECT_EQ(403, error_); | 237 EXPECT_EQ(403, error_); |
235 EXPECT_STREQ("network error", error_message_.c_str()); | 238 EXPECT_STREQ("network error", error_message_.c_str()); |
236 EXPECT_EQ(0ul, results_.list.size()); | 239 EXPECT_EQ(0ul, results_.list.size()); |
237 } | 240 } |
238 | 241 |
| 242 TEST_F(UpdateCheckerTest, UpdateCheckDownloadPreference) { |
| 243 EXPECT_TRUE(post_interceptor_->ExpectRequest( |
| 244 new PartialMatch("updatecheck"), test_file("updatecheck_reply_1.xml"))); |
| 245 |
| 246 config_->SetDownloadPreference(string("cacheable")); |
| 247 |
| 248 update_checker_ = UpdateChecker::Create(config_); |
| 249 |
| 250 CrxUpdateItem item(BuildCrxUpdateItem()); |
| 251 std::vector<CrxUpdateItem*> items_to_check; |
| 252 items_to_check.push_back(&item); |
| 253 |
| 254 update_checker_->CheckForUpdates( |
| 255 items_to_check, "extra=\"params\"", |
| 256 base::Bind(&UpdateCheckerTest::UpdateCheckComplete, |
| 257 base::Unretained(this))); |
| 258 |
| 259 RunThreads(); |
| 260 |
| 261 // The request must contain dlpref="cacheable". |
| 262 EXPECT_NE(string::npos, |
| 263 post_interceptor_->GetRequests()[0].find(" dlpref=\"cacheable\"")); |
| 264 } |
| 265 |
239 } // namespace update_client | 266 } // namespace update_client |
OLD | NEW |