OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_response.h" | 5 #include "components/update_client/update_response.h" |
6 #include "testing/gtest/include/gtest/gtest.h" | 6 #include "testing/gtest/include/gtest/gtest.h" |
7 | 7 |
8 namespace update_client { | 8 namespace update_client { |
9 | 9 |
10 const char* kValidXml = | 10 const char* kValidXml = |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 " <app appid='12345'>" | 197 " <app appid='12345'>" |
198 " <updatecheck status='noupdate'/>" | 198 " <updatecheck status='noupdate'/>" |
199 " </app>" | 199 " </app>" |
200 "</response>"; | 200 "</response>"; |
201 | 201 |
202 // Includes two <app> tags, one with an error. | 202 // Includes two <app> tags, one with an error. |
203 const char* kTwoAppsOneError = | 203 const char* kTwoAppsOneError = |
204 "<?xml version='1.0' encoding='UTF-8'?>" | 204 "<?xml version='1.0' encoding='UTF-8'?>" |
205 "<response protocol='3.0'>" | 205 "<response protocol='3.0'>" |
206 " <app appid='aaaaaaaa' status='error-unknownApplication'>" | 206 " <app appid='aaaaaaaa' status='error-unknownApplication'>" |
207 " <updatecheck status='error-unknownapplication'/>" | 207 " <updatecheck status='error-internal'/>" |
208 " </app>" | 208 " </app>" |
209 " <app appid='bbbbbbbb'>" | 209 " <app appid='bbbbbbbb'>" |
210 " <updatecheck status='ok'>" | 210 " <updatecheck status='ok'>" |
211 " <urls>" | 211 " <urls>" |
212 " <url codebase='http://example.com/'/>" | 212 " <url codebase='http://example.com/'/>" |
213 " </urls>" | 213 " </urls>" |
214 " <manifest version='1.2.3.4' prodversionmin='2.0.143.0'>" | 214 " <manifest version='1.2.3.4' prodversionmin='2.0.143.0'>" |
215 " <packages>" | 215 " <packages>" |
216 " <package name='extension_1_2_3_4.crx'/>" | 216 " <package name='extension_1_2_3_4.crx'/>" |
217 " </packages>" | 217 " </packages>" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 | 270 |
271 EXPECT_TRUE(parser.Parse(kInvalidValidXmlMissingManifest)); | 271 EXPECT_TRUE(parser.Parse(kInvalidValidXmlMissingManifest)); |
272 EXPECT_TRUE(parser.results().list.empty()); | 272 EXPECT_TRUE(parser.results().list.empty()); |
273 EXPECT_FALSE(parser.errors().empty()); | 273 EXPECT_FALSE(parser.errors().empty()); |
274 | 274 |
275 // Parse some valid XML, and check that all params came out as expected | 275 // Parse some valid XML, and check that all params came out as expected |
276 EXPECT_TRUE(parser.Parse(kValidXml)); | 276 EXPECT_TRUE(parser.Parse(kValidXml)); |
277 EXPECT_TRUE(parser.errors().empty()); | 277 EXPECT_TRUE(parser.errors().empty()); |
278 EXPECT_EQ(1u, parser.results().list.size()); | 278 EXPECT_EQ(1u, parser.results().list.size()); |
279 const UpdateResponse::Result* firstResult = &parser.results().list[0]; | 279 const UpdateResponse::Result* firstResult = &parser.results().list[0]; |
| 280 EXPECT_STREQ("ok", firstResult->status.c_str()); |
280 EXPECT_EQ(1u, firstResult->crx_urls.size()); | 281 EXPECT_EQ(1u, firstResult->crx_urls.size()); |
281 EXPECT_EQ(GURL("http://example.com/"), firstResult->crx_urls[0]); | 282 EXPECT_EQ(GURL("http://example.com/"), firstResult->crx_urls[0]); |
282 EXPECT_EQ(GURL("http://diff.example.com/"), firstResult->crx_diffurls[0]); | 283 EXPECT_EQ(GURL("http://diff.example.com/"), firstResult->crx_diffurls[0]); |
283 EXPECT_EQ("1.2.3.4", firstResult->manifest.version); | 284 EXPECT_EQ("1.2.3.4", firstResult->manifest.version); |
284 EXPECT_EQ("2.0.143.0", firstResult->manifest.browser_min_version); | 285 EXPECT_EQ("2.0.143.0", firstResult->manifest.browser_min_version); |
285 EXPECT_EQ(1u, firstResult->manifest.packages.size()); | 286 EXPECT_EQ(1u, firstResult->manifest.packages.size()); |
286 EXPECT_EQ("extension_1_2_3_4.crx", firstResult->manifest.packages[0].name); | 287 EXPECT_EQ("extension_1_2_3_4.crx", firstResult->manifest.packages[0].name); |
287 | 288 |
288 // Parse some xml that uses namespace prefixes. | 289 // Parse some xml that uses namespace prefixes. |
289 EXPECT_TRUE(parser.Parse(kUsesNamespacePrefix)); | 290 EXPECT_TRUE(parser.Parse(kUsesNamespacePrefix)); |
(...skipping 27 matching lines...) Expand all Loading... |
317 EXPECT_TRUE(parser.Parse(kWithDaystart)); | 318 EXPECT_TRUE(parser.Parse(kWithDaystart)); |
318 EXPECT_TRUE(parser.errors().empty()); | 319 EXPECT_TRUE(parser.errors().empty()); |
319 EXPECT_FALSE(parser.results().list.empty()); | 320 EXPECT_FALSE(parser.results().list.empty()); |
320 EXPECT_EQ(parser.results().daystart_elapsed_seconds, 456); | 321 EXPECT_EQ(parser.results().daystart_elapsed_seconds, 456); |
321 | 322 |
322 // Parse a no-update response. | 323 // Parse a no-update response. |
323 EXPECT_TRUE(parser.Parse(kNoUpdate)); | 324 EXPECT_TRUE(parser.Parse(kNoUpdate)); |
324 EXPECT_TRUE(parser.errors().empty()); | 325 EXPECT_TRUE(parser.errors().empty()); |
325 EXPECT_FALSE(parser.results().list.empty()); | 326 EXPECT_FALSE(parser.results().list.empty()); |
326 firstResult = &parser.results().list[0]; | 327 firstResult = &parser.results().list[0]; |
| 328 EXPECT_STREQ("noupdate", firstResult->status.c_str()); |
327 EXPECT_EQ(firstResult->extension_id, "12345"); | 329 EXPECT_EQ(firstResult->extension_id, "12345"); |
328 EXPECT_EQ(firstResult->manifest.version, ""); | 330 EXPECT_EQ(firstResult->manifest.version, ""); |
329 | 331 |
330 // Parse xml with one error and one success <app> tag. | 332 // Parse xml with one error and one success <app> tag. |
331 EXPECT_TRUE(parser.Parse(kTwoAppsOneError)); | 333 EXPECT_TRUE(parser.Parse(kTwoAppsOneError)); |
332 EXPECT_FALSE(parser.errors().empty()); | 334 EXPECT_FALSE(parser.errors().empty()); |
333 EXPECT_EQ(1u, parser.results().list.size()); | 335 EXPECT_EQ(1u, parser.results().list.size()); |
334 firstResult = &parser.results().list[0]; | 336 firstResult = &parser.results().list[0]; |
335 EXPECT_EQ(firstResult->extension_id, "bbbbbbbb"); | 337 EXPECT_EQ(firstResult->extension_id, "bbbbbbbb"); |
| 338 EXPECT_STREQ("ok", firstResult->status.c_str()); |
| 339 EXPECT_EQ("1.2.3.4", firstResult->manifest.version); |
336 | 340 |
337 // Parse xml with two apps setting the cohort info. | 341 // Parse xml with two apps setting the cohort info. |
338 EXPECT_TRUE(parser.Parse(kTwoAppsSetCohort)); | 342 EXPECT_TRUE(parser.Parse(kTwoAppsSetCohort)); |
339 EXPECT_TRUE(parser.errors().empty()); | 343 EXPECT_TRUE(parser.errors().empty()); |
340 EXPECT_EQ(2u, parser.results().list.size()); | 344 EXPECT_EQ(2u, parser.results().list.size()); |
341 firstResult = &parser.results().list[0]; | 345 firstResult = &parser.results().list[0]; |
342 EXPECT_EQ(firstResult->extension_id, "aaaaaaaa"); | 346 EXPECT_EQ(firstResult->extension_id, "aaaaaaaa"); |
343 EXPECT_NE(firstResult->cohort_attrs.find("cohort"), | 347 EXPECT_NE(firstResult->cohort_attrs.find("cohort"), |
344 firstResult->cohort_attrs.end()); | 348 firstResult->cohort_attrs.end()); |
345 EXPECT_EQ(firstResult->cohort_attrs.find("cohort")->second, "1:2q3/"); | 349 EXPECT_EQ(firstResult->cohort_attrs.find("cohort")->second, "1:2q3/"); |
346 EXPECT_EQ(firstResult->cohort_attrs.find("cohortname"), | 350 EXPECT_EQ(firstResult->cohort_attrs.find("cohortname"), |
347 firstResult->cohort_attrs.end()); | 351 firstResult->cohort_attrs.end()); |
348 EXPECT_EQ(firstResult->cohort_attrs.find("cohorthint"), | 352 EXPECT_EQ(firstResult->cohort_attrs.find("cohorthint"), |
349 firstResult->cohort_attrs.end()); | 353 firstResult->cohort_attrs.end()); |
350 const UpdateResponse::Result* secondResult = &parser.results().list[1]; | 354 const UpdateResponse::Result* secondResult = &parser.results().list[1]; |
351 EXPECT_EQ(secondResult->extension_id, "bbbbbbbb"); | 355 EXPECT_EQ(secondResult->extension_id, "bbbbbbbb"); |
352 EXPECT_NE(secondResult->cohort_attrs.find("cohort"), | 356 EXPECT_NE(secondResult->cohort_attrs.find("cohort"), |
353 secondResult->cohort_attrs.end()); | 357 secondResult->cohort_attrs.end()); |
354 EXPECT_EQ(secondResult->cohort_attrs.find("cohort")->second, "1:33z@0.33"); | 358 EXPECT_EQ(secondResult->cohort_attrs.find("cohort")->second, "1:33z@0.33"); |
355 EXPECT_NE(secondResult->cohort_attrs.find("cohortname"), | 359 EXPECT_NE(secondResult->cohort_attrs.find("cohortname"), |
356 secondResult->cohort_attrs.end()); | 360 secondResult->cohort_attrs.end()); |
357 EXPECT_EQ(secondResult->cohort_attrs.find("cohortname")->second, "cname"); | 361 EXPECT_EQ(secondResult->cohort_attrs.find("cohortname")->second, "cname"); |
358 EXPECT_EQ(secondResult->cohort_attrs.find("cohorthint"), | 362 EXPECT_EQ(secondResult->cohort_attrs.find("cohorthint"), |
359 secondResult->cohort_attrs.end()); | 363 secondResult->cohort_attrs.end()); |
360 } | 364 } |
361 | 365 |
362 } // namespace update_client | 366 } // namespace update_client |
OLD | NEW |