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

Side by Side Diff: components/update_client/update_checker_unittest.cc

Issue 2847023002: Parse update check run actions for the component updater. (Closed)
Patch Set: Added missing data file dependency. Created 3 years, 7 months 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 // 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 "components/update_client/update_checker.h" 5 #include "components/update_client/update_checker.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 RunThreads(); 198 RunThreads();
199 199
200 EXPECT_EQ(1, post_interceptor_->GetHitCount()) 200 EXPECT_EQ(1, post_interceptor_->GetHitCount())
201 << post_interceptor_->GetRequestsAsString(); 201 << post_interceptor_->GetRequestsAsString();
202 ASSERT_EQ(1, post_interceptor_->GetCount()) 202 ASSERT_EQ(1, post_interceptor_->GetCount())
203 << post_interceptor_->GetRequestsAsString(); 203 << post_interceptor_->GetRequestsAsString();
204 204
205 // Sanity check the request. 205 // Sanity check the request.
206 const auto request = post_interceptor_->GetRequests()[0]; 206 const auto request = post_interceptor_->GetRequests()[0];
207 EXPECT_NE(string::npos, post_interceptor_->GetRequests()[0].find( 207 EXPECT_NE(string::npos, post_interceptor_->GetRequests()[0].find(
208 "request protocol=\"3.0\" extra=\"params\"")); 208 "request protocol=\"3.1\" extra=\"params\""));
209 // The request must not contain any "dlpref" in the default case. 209 // The request must not contain any "dlpref" in the default case.
210 EXPECT_EQ(string::npos, request.find(" dlpref=\"")); 210 EXPECT_EQ(string::npos, request.find(" dlpref=\""));
211 EXPECT_NE( 211 EXPECT_NE(
212 string::npos, 212 string::npos,
213 request.find( 213 request.find(
214 std::string("<app appid=\"") + kUpdateItemId + 214 std::string("<app appid=\"") + kUpdateItemId +
215 "\" version=\"0.9\" " 215 "\" version=\"0.9\" "
216 "brand=\"TEST\" ap=\"some_ap\"><updatecheck/><ping rd=\"-2\" ")); 216 "brand=\"TEST\" ap=\"some_ap\"><updatecheck/><ping rd=\"-2\" "));
217 EXPECT_NE(string::npos, 217 EXPECT_NE(string::npos,
218 request.find("<packages><package fp=\"fp1\"/></packages></app>")); 218 request.find("<packages><package fp=\"fp1\"/></packages></app>"));
219 219
220 EXPECT_NE(string::npos, request.find("<hw physmemory=")); 220 EXPECT_NE(string::npos, request.find("<hw physmemory="));
221 221
222 // Tests that the progid is injected correctly from the configurator. 222 // Tests that the progid is injected correctly from the configurator.
223 EXPECT_NE( 223 EXPECT_NE(
224 string::npos, 224 string::npos,
225 request.find(" version=\"fake_prodid-30.0\" prodversion=\"30.0\" ")); 225 request.find(" version=\"fake_prodid-30.0\" prodversion=\"30.0\" "));
226 226
227 // Sanity check the arguments of the callback after parsing. 227 // Sanity check the arguments of the callback after parsing.
228 EXPECT_EQ(0, error_); 228 EXPECT_EQ(0, error_);
229 229
230 EXPECT_EQ(base::Version("1.0"), component->next_version_); 230 EXPECT_EQ(base::Version("1.0"), component->next_version_);
231 EXPECT_EQ(1u, component->crx_urls_.size()); 231 EXPECT_EQ(1u, component->crx_urls_.size());
232 EXPECT_EQ( 232 EXPECT_EQ(
233 GURL("http://localhost/download/jebgalgnebhfojomionfpkfelancnnkf.crx"), 233 GURL("http://localhost/download/jebgalgnebhfojomionfpkfelancnnkf.crx"),
234 component->crx_urls_.front()); 234 component->crx_urls_.front());
235 235
236 EXPECT_STREQ("this", component->action_run_.c_str());
237
236 #if (OS_WIN) 238 #if (OS_WIN)
237 EXPECT_NE(string::npos, request.find(" domainjoined=")); 239 EXPECT_NE(string::npos, request.find(" domainjoined="));
238 #if defined(GOOGLE_CHROME_BUILD) 240 #if defined(GOOGLE_CHROME_BUILD)
239 // Check the Omaha updater state data in the request. 241 // Check the Omaha updater state data in the request.
240 EXPECT_NE(string::npos, request.find("<updater ")); 242 EXPECT_NE(string::npos, request.find("<updater "));
241 EXPECT_NE(string::npos, request.find(" name=\"Omaha\" ")); 243 EXPECT_NE(string::npos, request.find(" name=\"Omaha\" "));
242 #endif // GOOGLE_CHROME_BUILD 244 #endif // GOOGLE_CHROME_BUILD
243 #endif // OS_WINDOWS 245 #endif // OS_WINDOWS
244 } 246 }
245 247
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 std::vector<std::string>{kUpdateItemId}, components, "", true, 530 std::vector<std::string>{kUpdateItemId}, components, "", true,
529 base::Bind(&UpdateCheckerTest::UpdateCheckComplete, 531 base::Bind(&UpdateCheckerTest::UpdateCheckComplete,
530 base::Unretained(this))); 532 base::Unretained(this)));
531 RunThreads(); 533 RunThreads();
532 EXPECT_NE(string::npos, post_interceptor_->GetRequests()[3].find( 534 EXPECT_NE(string::npos, post_interceptor_->GetRequests()[3].find(
533 std::string("<app appid=\"") + kUpdateItemId + 535 std::string("<app appid=\"") + kUpdateItemId +
534 "\" version=\"0.9\">" 536 "\" version=\"0.9\">"
535 "<updatecheck/>")); 537 "<updatecheck/>"));
536 } 538 }
537 539
540 TEST_F(UpdateCheckerTest, NoUpdateActionRun) {
541 EXPECT_TRUE(post_interceptor_->ExpectRequest(
542 new PartialMatch("updatecheck"),
543 test_file("updatecheck_reply_noupdate.xml")));
544
545 update_checker_ = UpdateChecker::Create(config_, metadata_.get());
546
547 IdToComponentPtrMap components;
548 components[kUpdateItemId] = MakeComponent();
549
550 auto& component = components[kUpdateItemId];
551
552 update_checker_->CheckForUpdates(
553 std::vector<std::string>{kUpdateItemId}, components, "", true,
554 base::Bind(&UpdateCheckerTest::UpdateCheckComplete,
555 base::Unretained(this)));
556 RunThreads();
557
558 EXPECT_EQ(1, post_interceptor_->GetHitCount())
559 << post_interceptor_->GetRequestsAsString();
560 ASSERT_EQ(1, post_interceptor_->GetCount())
561 << post_interceptor_->GetRequestsAsString();
562
563 EXPECT_EQ(0, error_);
564 EXPECT_STREQ("this", component->action_run_.c_str());
565 }
566
538 } // namespace update_client 567 } // namespace update_client
OLDNEW
« no previous file with comments | « components/update_client/request_sender_unittest.cc ('k') | components/update_client/update_response.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698