| 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/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/compiler_specific.h" | 6 #include "base/compiler_specific.h" |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| 11 #include "base/run_loop.h" | 11 #include "base/run_loop.h" |
| 12 #include "base/version.h" | 12 #include "base/version.h" |
| 13 #include "chrome/browser/component_updater/crx_update_item.h" | 13 #include "chrome/browser/component_updater/crx_update_item.h" |
| 14 #include "chrome/browser/component_updater/test/component_updater_service_unitte
st.h" | 14 #include "chrome/browser/component_updater/test/component_updater_service_unitte
st.h" |
| 15 #include "chrome/browser/component_updater/test/url_request_post_interceptor.h" | 15 #include "chrome/browser/component_updater/test/url_request_post_interceptor.h" |
| 16 #include "chrome/browser/component_updater/update_checker.h" | 16 #include "chrome/browser/component_updater/update_checker.h" |
| 17 #include "chrome/common/chrome_paths.h" | 17 #include "chrome/common/chrome_paths.h" |
| 18 #include "chrome/common/chrome_version_info.h" |
| 18 #include "content/public/browser/browser_thread.h" | 19 #include "content/public/browser/browser_thread.h" |
| 19 #include "content/public/test/test_browser_thread_bundle.h" | 20 #include "content/public/test/test_browser_thread_bundle.h" |
| 20 #include "net/url_request/url_fetcher.h" | 21 #include "net/url_request/url_fetcher.h" |
| 21 #include "net/url_request/url_request_test_util.h" | 22 #include "net/url_request/url_request_test_util.h" |
| 22 #include "testing/gtest/include/gtest/gtest.h" | 23 #include "testing/gtest/include/gtest/gtest.h" |
| 23 | 24 |
| 24 using content::BrowserThread; | 25 using content::BrowserThread; |
| 25 | 26 |
| 26 namespace component_updater { | 27 namespace component_updater { |
| 27 | 28 |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 update_checker_ = | 166 update_checker_ = |
| 166 UpdateChecker::Create(GURL("https://localhost2/update2"), | 167 UpdateChecker::Create(GURL("https://localhost2/update2"), |
| 167 context(), | 168 context(), |
| 168 base::Bind(&UpdateCheckerTest::UpdateCheckComplete, | 169 base::Bind(&UpdateCheckerTest::UpdateCheckComplete, |
| 169 base::Unretained(this))).Pass(); | 170 base::Unretained(this))).Pass(); |
| 170 | 171 |
| 171 CrxUpdateItem item(BuildCrxUpdateItem()); | 172 CrxUpdateItem item(BuildCrxUpdateItem()); |
| 172 std::vector<CrxUpdateItem*> items_to_check; | 173 std::vector<CrxUpdateItem*> items_to_check; |
| 173 items_to_check.push_back(&item); | 174 items_to_check.push_back(&item); |
| 174 | 175 |
| 175 update_checker_->CheckForUpdates(items_to_check, "extra=\"params\""); | 176 update_checker_->CheckForUpdates(chrome::VersionInfo().Version(), |
| 177 chrome::VersionInfo().OSType(), |
| 178 items_to_check, "extra=\"params\""); |
| 176 | 179 |
| 177 RunThreads(); | 180 RunThreads(); |
| 178 | 181 |
| 179 EXPECT_EQ(1, post_interceptor_->GetHitCount()) | 182 EXPECT_EQ(1, post_interceptor_->GetHitCount()) |
| 180 << post_interceptor_->GetRequestsAsString(); | 183 << post_interceptor_->GetRequestsAsString(); |
| 181 EXPECT_EQ(1, post_interceptor_->GetCount()) | 184 EXPECT_EQ(1, post_interceptor_->GetCount()) |
| 182 << post_interceptor_->GetRequestsAsString(); | 185 << post_interceptor_->GetRequestsAsString(); |
| 183 | 186 |
| 184 // Sanity check the request. | 187 // Sanity check the request. |
| 185 EXPECT_NE( | 188 EXPECT_NE( |
| (...skipping 29 matching lines...) Expand all Loading... |
| 215 update_checker_ = | 218 update_checker_ = |
| 216 UpdateChecker::Create(GURL("https://localhost2/update2"), | 219 UpdateChecker::Create(GURL("https://localhost2/update2"), |
| 217 context(), | 220 context(), |
| 218 base::Bind(&UpdateCheckerTest::UpdateCheckComplete, | 221 base::Bind(&UpdateCheckerTest::UpdateCheckComplete, |
| 219 base::Unretained(this))).Pass(); | 222 base::Unretained(this))).Pass(); |
| 220 | 223 |
| 221 CrxUpdateItem item(BuildCrxUpdateItem()); | 224 CrxUpdateItem item(BuildCrxUpdateItem()); |
| 222 std::vector<CrxUpdateItem*> items_to_check; | 225 std::vector<CrxUpdateItem*> items_to_check; |
| 223 items_to_check.push_back(&item); | 226 items_to_check.push_back(&item); |
| 224 | 227 |
| 225 update_checker_->CheckForUpdates(items_to_check, ""); | 228 update_checker_->CheckForUpdates(chrome::VersionInfo().Version(), |
| 229 chrome::VersionInfo().OSType(), |
| 230 items_to_check, ""); |
| 226 | 231 |
| 227 RunThreads(); | 232 RunThreads(); |
| 228 | 233 |
| 229 EXPECT_EQ(0, post_interceptor_->GetHitCount()) | 234 EXPECT_EQ(0, post_interceptor_->GetHitCount()) |
| 230 << post_interceptor_->GetRequestsAsString(); | 235 << post_interceptor_->GetRequestsAsString(); |
| 231 EXPECT_EQ(1, post_interceptor_->GetCount()) | 236 EXPECT_EQ(1, post_interceptor_->GetCount()) |
| 232 << post_interceptor_->GetRequestsAsString(); | 237 << post_interceptor_->GetRequestsAsString(); |
| 233 | 238 |
| 234 EXPECT_NE(0, error_); | 239 EXPECT_NE(0, error_); |
| 235 EXPECT_STREQ("network error", error_message_.c_str()); | 240 EXPECT_STREQ("network error", error_message_.c_str()); |
| 236 EXPECT_EQ(0ul, results_.list.size()); | 241 EXPECT_EQ(0ul, results_.list.size()); |
| 237 } | 242 } |
| 238 | 243 |
| 239 } // namespace component_updater | 244 } // namespace component_updater |
| OLD | NEW |