| 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 " </urls>" | 92 " </urls>" |
| 93 " </updatecheck>" | 93 " </updatecheck>" |
| 94 " </app>" | 94 " </app>" |
| 95 "</response>"; | 95 "</response>"; |
| 96 | 96 |
| 97 const char* kMissingAppId = | 97 const char* kMissingAppId = |
| 98 "<?xml version='1.0'?>" | 98 "<?xml version='1.0'?>" |
| 99 "<response protocol='3.0'>" | 99 "<response protocol='3.0'>" |
| 100 " <app>" | 100 " <app>" |
| 101 " <updatecheck codebase='http://example.com/extension_1.2.3.4.crx'" | 101 " <updatecheck codebase='http://example.com/extension_1.2.3.4.crx'" |
| 102 " version='1.2.3.4' />" | 102 " version='1.2.3.4'/>" |
| 103 " </app>" | 103 " </app>" |
| 104 "</response>"; | 104 "</response>"; |
| 105 | 105 |
| 106 const char* kInvalidCodebase = | 106 const char* kInvalidCodebase = |
| 107 "<?xml version='1.0'?>" | 107 "<?xml version='1.0'?>" |
| 108 "<response protocol='3.0'>" | 108 "<response protocol='3.0'>" |
| 109 " <app appid='12345' status='ok'>" | 109 " <app appid='12345' status='ok'>" |
| 110 " <updatecheck codebase='example.com/extension_1.2.3.4.crx'" | 110 " <updatecheck codebase='example.com/extension_1.2.3.4.crx'" |
| 111 " version='1.2.3.4' />" | 111 " version='1.2.3.4'/>" |
| 112 " </app>" | 112 " </app>" |
| 113 "</response>"; | 113 "</response>"; |
| 114 | 114 |
| 115 const char* kMissingVersion = | 115 const char* kMissingVersion = |
| 116 "<?xml version='1.0'?>" | 116 "<?xml version='1.0'?>" |
| 117 "<response protocol='3.0'>" | 117 "<response protocol='3.0'>" |
| 118 " <app appid='12345' status='ok'>" | 118 " <app appid='12345' status='ok'>" |
| 119 " <updatecheck codebase='http://example.com/extension_1.2.3.4.crx' />" | 119 " <updatecheck codebase='http://example.com/extension_1.2.3.4.crx'/>" |
| 120 " </app>" | 120 " </app>" |
| 121 "</response>"; | 121 "</response>"; |
| 122 | 122 |
| 123 const char* kInvalidVersion = | 123 const char* kInvalidVersion = |
| 124 "<?xml version='1.0'?>" | 124 "<?xml version='1.0'?>" |
| 125 "<response protocol='3.0'>" | 125 "<response protocol='3.0'>" |
| 126 " <app appid='12345' status='ok'>" | 126 " <app appid='12345' status='ok'>" |
| 127 " <updatecheck codebase='http://example.com/extension_1.2.3.4.crx' " | 127 " <updatecheck codebase='http://example.com/extension_1.2.3.4.crx' " |
| 128 " version='1.2.3.a'/>" | 128 " version='1.2.3.a'/>" |
| 129 " </app>" | 129 " </app>" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 " </a:app>" | 168 " </a:app>" |
| 169 " <b:app appid='xyz' xmlns:b='http://b'>" | 169 " <b:app appid='xyz' xmlns:b='http://b'>" |
| 170 " <updatecheck status='noupdate'/>" | 170 " <updatecheck status='noupdate'/>" |
| 171 " </b:app>" | 171 " </b:app>" |
| 172 "</response>"; | 172 "</response>"; |
| 173 | 173 |
| 174 // Includes a <daystart> tag. | 174 // Includes a <daystart> tag. |
| 175 const char* kWithDaystart = | 175 const char* kWithDaystart = |
| 176 "<?xml version='1.0' encoding='UTF-8'?>" | 176 "<?xml version='1.0' encoding='UTF-8'?>" |
| 177 "<response protocol='3.0'>" | 177 "<response protocol='3.0'>" |
| 178 " <daystart elapsed_seconds='456' />" | 178 " <daystart elapsed_seconds='456'/>" |
| 179 " <app appid='12345'>" | 179 " <app appid='12345'>" |
| 180 " <updatecheck status='ok'>" | 180 " <updatecheck status='ok'>" |
| 181 " <urls>" | 181 " <urls>" |
| 182 " <url codebase='http://example.com/'/>" | 182 " <url codebase='http://example.com/'/>" |
| 183 " </urls>" | 183 " </urls>" |
| 184 " <manifest version='1.2.3.4' prodversionmin='2.0.143.0'>" | 184 " <manifest version='1.2.3.4' prodversionmin='2.0.143.0'>" |
| 185 " <packages>" | 185 " <packages>" |
| 186 " <package name='extension_1_2_3_4.crx'/>" | 186 " <package name='extension_1_2_3_4.crx'/>" |
| 187 " </packages>" | 187 " </packages>" |
| 188 " </manifest>" | 188 " </manifest>" |
| 189 " </updatecheck>" | 189 " </updatecheck>" |
| 190 " </app>" | 190 " </app>" |
| 191 "</response>"; | 191 "</response>"; |
| 192 | 192 |
| 193 // Indicates no updates available - this should not be a parse error. | 193 // Indicates no updates available - this should not be a parse error. |
| 194 const char* kNoUpdate = | 194 const char* kNoUpdate = |
| 195 "<?xml version='1.0' encoding='UTF-8'?>" | 195 "<?xml version='1.0' encoding='UTF-8'?>" |
| 196 "<response protocol='3.0'>" | 196 "<response protocol='3.0'>" |
| 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-unknownapplication'/>" |
| 208 " </app>" | 208 " </app>" |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 secondResult->cohort_attrs.end()); | 353 secondResult->cohort_attrs.end()); |
| 354 EXPECT_EQ(secondResult->cohort_attrs.find("cohort")->second, "1:33z@0.33"); | 354 EXPECT_EQ(secondResult->cohort_attrs.find("cohort")->second, "1:33z@0.33"); |
| 355 EXPECT_NE(secondResult->cohort_attrs.find("cohortname"), | 355 EXPECT_NE(secondResult->cohort_attrs.find("cohortname"), |
| 356 secondResult->cohort_attrs.end()); | 356 secondResult->cohort_attrs.end()); |
| 357 EXPECT_EQ(secondResult->cohort_attrs.find("cohortname")->second, "cname"); | 357 EXPECT_EQ(secondResult->cohort_attrs.find("cohortname")->second, "cname"); |
| 358 EXPECT_EQ(secondResult->cohort_attrs.find("cohorthint"), | 358 EXPECT_EQ(secondResult->cohort_attrs.find("cohorthint"), |
| 359 secondResult->cohort_attrs.end()); | 359 secondResult->cohort_attrs.end()); |
| 360 } | 360 } |
| 361 | 361 |
| 362 } // namespace update_client | 362 } // namespace update_client |
| OLD | NEW |