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

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

Issue 1823273002: Send the value of google_brand::GetBrand in component update checks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: minor unit test improvement. Created 4 years, 9 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
« no previous file with comments | « components/update_client/update_checker.cc ('k') | components/update_client/utils.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/bind_helpers.h" 6 #include "base/bind_helpers.h"
7 #include "base/files/file_util.h" 7 #include "base/files/file_util.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 175
176 // Sanity check the request. 176 // Sanity check the request.
177 EXPECT_NE(string::npos, post_interceptor_->GetRequests()[0].find( 177 EXPECT_NE(string::npos, post_interceptor_->GetRequests()[0].find(
178 "request protocol=\"3.0\" extra=\"params\"")); 178 "request protocol=\"3.0\" extra=\"params\""));
179 // The request must not contain any "dlpref" in the default case. 179 // The request must not contain any "dlpref" in the default case.
180 EXPECT_EQ(string::npos, 180 EXPECT_EQ(string::npos,
181 post_interceptor_->GetRequests()[0].find(" dlpref=\"")); 181 post_interceptor_->GetRequests()[0].find(" dlpref=\""));
182 EXPECT_NE( 182 EXPECT_NE(
183 string::npos, 183 string::npos,
184 post_interceptor_->GetRequests()[0].find( 184 post_interceptor_->GetRequests()[0].find(
185 "app appid=\"jebgalgnebhfojomionfpkfelancnnkf\" version=\"0.9\">" 185 "app appid=\"jebgalgnebhfojomionfpkfelancnnkf\" version=\"0.9\" "
186 "<updatecheck /><packages><package fp=\"fp1\"/></packages></app>")); 186 "brand=\"TEST\"><updatecheck />"
187 "<packages><package fp=\"fp1\"/></packages></app>"));
187 188
188 EXPECT_NE(string::npos, 189 EXPECT_NE(string::npos,
189 post_interceptor_->GetRequests()[0].find("<hw physmemory=")); 190 post_interceptor_->GetRequests()[0].find("<hw physmemory="));
190 191
191 // Sanity check the arguments of the callback after parsing. 192 // Sanity check the arguments of the callback after parsing.
192 EXPECT_EQ(0, error_); 193 EXPECT_EQ(0, error_);
193 EXPECT_EQ(1ul, results_.list.size()); 194 EXPECT_EQ(1ul, results_.list.size());
194 EXPECT_STREQ("jebgalgnebhfojomionfpkfelancnnkf", 195 EXPECT_STREQ("jebgalgnebhfojomionfpkfelancnnkf",
195 results_.list[0].extension_id.c_str()); 196 results_.list[0].extension_id.c_str());
196 EXPECT_STREQ("1.0", results_.list[0].manifest.version.c_str()); 197 EXPECT_STREQ("1.0", results_.list[0].manifest.version.c_str());
197 } 198 }
198 199
200 TEST_F(UpdateCheckerTest, UpdateCheckSuccessNoBrand) {
201 EXPECT_TRUE(post_interceptor_->ExpectRequest(
202 new PartialMatch("updatecheck"), test_file("updatecheck_reply_1.xml")));
203
204 config_->SetBrand("TOOLONG"); // Sets an invalid brand code.
205 update_checker_ = UpdateChecker::Create(config_);
206
207 CrxUpdateItem item(BuildCrxUpdateItem());
208 std::vector<CrxUpdateItem*> items_to_check;
209 items_to_check.push_back(&item);
210
211 update_checker_->CheckForUpdates(
212 items_to_check, "", base::Bind(&UpdateCheckerTest::UpdateCheckComplete,
213 base::Unretained(this)));
214
215 RunThreads();
216
217 EXPECT_NE(
218 string::npos,
219 post_interceptor_->GetRequests()[0].find(
220 "app appid=\"jebgalgnebhfojomionfpkfelancnnkf\" version=\"0.9\">"
221 "<updatecheck /><packages><package fp=\"fp1\"/></packages></app>"));
222 }
223
199 // Simulates a 403 server response error. 224 // Simulates a 403 server response error.
200 TEST_F(UpdateCheckerTest, UpdateCheckError) { 225 TEST_F(UpdateCheckerTest, UpdateCheckError) {
201 EXPECT_TRUE( 226 EXPECT_TRUE(
202 post_interceptor_->ExpectRequest(new PartialMatch("updatecheck"), 403)); 227 post_interceptor_->ExpectRequest(new PartialMatch("updatecheck"), 403));
203 228
204 update_checker_ = UpdateChecker::Create(config_); 229 update_checker_ = UpdateChecker::Create(config_);
205 230
206 CrxUpdateItem item(BuildCrxUpdateItem()); 231 CrxUpdateItem item(BuildCrxUpdateItem());
207 std::vector<CrxUpdateItem*> items_to_check; 232 std::vector<CrxUpdateItem*> items_to_check;
208 items_to_check.push_back(&item); 233 items_to_check.push_back(&item);
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 292
268 EXPECT_EQ(1, post_interceptor_->GetHitCount()) 293 EXPECT_EQ(1, post_interceptor_->GetHitCount())
269 << post_interceptor_->GetRequestsAsString(); 294 << post_interceptor_->GetRequestsAsString();
270 ASSERT_EQ(1, post_interceptor_->GetCount()) 295 ASSERT_EQ(1, post_interceptor_->GetCount())
271 << post_interceptor_->GetRequestsAsString(); 296 << post_interceptor_->GetRequestsAsString();
272 297
273 // Sanity check the request. 298 // Sanity check the request.
274 EXPECT_NE( 299 EXPECT_NE(
275 string::npos, 300 string::npos,
276 post_interceptor_->GetRequests()[0].find( 301 post_interceptor_->GetRequests()[0].find(
277 "app appid=\"jebgalgnebhfojomionfpkfelancnnkf\" version=\"0.9\">" 302 "app appid=\"jebgalgnebhfojomionfpkfelancnnkf\" version=\"0.9\" "
278 "<updatecheck /><packages><package fp=\"fp1\"/></packages></app>")); 303 "brand=\"TEST\"><updatecheck />"
304 "<packages><package fp=\"fp1\"/></packages></app>"));
279 305
280 // Expect an error since the response is not trusted. 306 // Expect an error since the response is not trusted.
281 EXPECT_EQ(-10000, error_); 307 EXPECT_EQ(-10000, error_);
282 EXPECT_EQ(0ul, results_.list.size()); 308 EXPECT_EQ(0ul, results_.list.size());
283 } 309 }
284 310
285 } // namespace update_client 311 } // namespace update_client
OLDNEW
« no previous file with comments | « components/update_client/update_checker.cc ('k') | components/update_client/utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698