| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <list> | 5 #include <list> |
| 6 #include <map> | 6 #include <map> |
| 7 #include <set> | 7 #include <set> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 #include "chrome/browser/extensions/extension_sync_data.h" | 29 #include "chrome/browser/extensions/extension_sync_data.h" |
| 30 #include "chrome/browser/extensions/test_extension_prefs.h" | 30 #include "chrome/browser/extensions/test_extension_prefs.h" |
| 31 #include "chrome/browser/extensions/test_extension_service.h" | 31 #include "chrome/browser/extensions/test_extension_service.h" |
| 32 #include "chrome/browser/extensions/test_extension_system.h" | 32 #include "chrome/browser/extensions/test_extension_system.h" |
| 33 #include "chrome/browser/extensions/updater/chrome_extension_downloader_factory.
h" | 33 #include "chrome/browser/extensions/updater/chrome_extension_downloader_factory.
h" |
| 34 #include "chrome/browser/extensions/updater/extension_updater.h" | 34 #include "chrome/browser/extensions/updater/extension_updater.h" |
| 35 #include "chrome/browser/google/google_brand.h" | 35 #include "chrome/browser/google/google_brand.h" |
| 36 #include "chrome/browser/prefs/pref_service_syncable.h" | 36 #include "chrome/browser/prefs/pref_service_syncable.h" |
| 37 #include "chrome/test/base/testing_profile.h" | 37 #include "chrome/test/base/testing_profile.h" |
| 38 #include "components/crx_file/id_util.h" | 38 #include "components/crx_file/id_util.h" |
| 39 #include "components/omaha_client/omaha_query_params.h" | 39 #include "components/update_client/update_query_params.h" |
| 40 #include "content/public/browser/notification_details.h" | 40 #include "content/public/browser/notification_details.h" |
| 41 #include "content/public/browser/notification_observer.h" | 41 #include "content/public/browser/notification_observer.h" |
| 42 #include "content/public/browser/notification_registrar.h" | 42 #include "content/public/browser/notification_registrar.h" |
| 43 #include "content/public/browser/notification_service.h" | 43 #include "content/public/browser/notification_service.h" |
| 44 #include "content/public/browser/notification_source.h" | 44 #include "content/public/browser/notification_source.h" |
| 45 #include "content/public/test/test_browser_thread_bundle.h" | 45 #include "content/public/test/test_browser_thread_bundle.h" |
| 46 #include "content/public/test/test_utils.h" | 46 #include "content/public/test/test_utils.h" |
| 47 #include "extensions/browser/extension_prefs.h" | 47 #include "extensions/browser/extension_prefs.h" |
| 48 #include "extensions/browser/extension_registry.h" | 48 #include "extensions/browser/extension_registry.h" |
| 49 #include "extensions/browser/extension_system.h" | 49 #include "extensions/browser/extension_system.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 69 | 69 |
| 70 #if defined(OS_CHROMEOS) | 70 #if defined(OS_CHROMEOS) |
| 71 #include "chrome/browser/chromeos/login/users/scoped_test_user_manager.h" | 71 #include "chrome/browser/chromeos/login/users/scoped_test_user_manager.h" |
| 72 #include "chrome/browser/chromeos/settings/cros_settings.h" | 72 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 73 #include "chrome/browser/chromeos/settings/device_settings_service.h" | 73 #include "chrome/browser/chromeos/settings/device_settings_service.h" |
| 74 #endif | 74 #endif |
| 75 | 75 |
| 76 using base::Time; | 76 using base::Time; |
| 77 using base::TimeDelta; | 77 using base::TimeDelta; |
| 78 using content::BrowserThread; | 78 using content::BrowserThread; |
| 79 using omaha_client::OmahaQueryParams; | 79 using update_client::UpdateQueryParams; |
| 80 using testing::DoAll; | 80 using testing::DoAll; |
| 81 using testing::Invoke; | 81 using testing::Invoke; |
| 82 using testing::InvokeWithoutArgs; | 82 using testing::InvokeWithoutArgs; |
| 83 using testing::Mock; | 83 using testing::Mock; |
| 84 using testing::Return; | 84 using testing::Return; |
| 85 using testing::SetArgPointee; | 85 using testing::SetArgPointee; |
| 86 using testing::_; | 86 using testing::_; |
| 87 | 87 |
| 88 namespace extensions { | 88 namespace extensions { |
| 89 | 89 |
| (...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 611 } | 611 } |
| 612 return result; | 612 return result; |
| 613 } | 613 } |
| 614 | 614 |
| 615 static void VerifyQueryAndExtractParameters( | 615 static void VerifyQueryAndExtractParameters( |
| 616 const std::string& query, | 616 const std::string& query, |
| 617 std::map<std::string, std::string>* result) { | 617 std::map<std::string, std::string>* result) { |
| 618 std::map<std::string, std::string> params; | 618 std::map<std::string, std::string> params; |
| 619 ExtractParameters(query, ¶ms); | 619 ExtractParameters(query, ¶ms); |
| 620 | 620 |
| 621 std::string omaha_params = OmahaQueryParams::Get(OmahaQueryParams::CRX); | 621 std::string omaha_params = UpdateQueryParams::Get(UpdateQueryParams::CRX); |
| 622 std::map<std::string, std::string> expected; | 622 std::map<std::string, std::string> expected; |
| 623 ExtractParameters(omaha_params, &expected); | 623 ExtractParameters(omaha_params, &expected); |
| 624 | 624 |
| 625 for (std::map<std::string, std::string>::iterator it = expected.begin(); | 625 for (std::map<std::string, std::string>::iterator it = expected.begin(); |
| 626 it != expected.end(); ++it) { | 626 it != expected.end(); ++it) { |
| 627 EXPECT_EQ(it->second, params[it->first]); | 627 EXPECT_EQ(it->second, params[it->first]); |
| 628 } | 628 } |
| 629 | 629 |
| 630 EXPECT_EQ(1U, params.count("x")); | 630 EXPECT_EQ(1U, params.count("x")); |
| 631 std::string decoded = net::UnescapeURLComponent( | 631 std::string decoded = net::UnescapeURLComponent( |
| (...skipping 1257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1889 } | 1889 } |
| 1890 EXPECT_EQ(disable_reasons, found_reasons); | 1890 EXPECT_EQ(disable_reasons, found_reasons); |
| 1891 } | 1891 } |
| 1892 } | 1892 } |
| 1893 } | 1893 } |
| 1894 | 1894 |
| 1895 protected: | 1895 protected: |
| 1896 scoped_ptr<TestExtensionPrefs> prefs_; | 1896 scoped_ptr<TestExtensionPrefs> prefs_; |
| 1897 | 1897 |
| 1898 ManifestFetchData* CreateManifestFetchData(const GURL& update_url) { | 1898 ManifestFetchData* CreateManifestFetchData(const GURL& update_url) { |
| 1899 return new ManifestFetchData(update_url, | 1899 return new ManifestFetchData(update_url, 0, "", |
| 1900 0, | 1900 UpdateQueryParams::Get(UpdateQueryParams::CRX), |
| 1901 "", | |
| 1902 OmahaQueryParams::Get(OmahaQueryParams::CRX), | |
| 1903 ManifestFetchData::PING); | 1901 ManifestFetchData::PING); |
| 1904 } | 1902 } |
| 1905 | 1903 |
| 1906 private: | 1904 private: |
| 1907 content::TestBrowserThreadBundle thread_bundle_; | 1905 content::TestBrowserThreadBundle thread_bundle_; |
| 1908 content::InProcessUtilityThreadHelper in_process_utility_thread_helper_; | 1906 content::InProcessUtilityThreadHelper in_process_utility_thread_helper_; |
| 1909 | 1907 |
| 1910 #if defined OS_CHROMEOS | 1908 #if defined OS_CHROMEOS |
| 1911 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; | 1909 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; |
| 1912 chromeos::ScopedTestCrosSettings test_cros_settings_; | 1910 chromeos::ScopedTestCrosSettings test_cros_settings_; |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2180 ASSERT_TRUE(fetcher); | 2178 ASSERT_TRUE(fetcher); |
| 2181 EXPECT_FALSE(fetcher->GetOriginalURL().is_empty()); | 2179 EXPECT_FALSE(fetcher->GetOriginalURL().is_empty()); |
| 2182 } | 2180 } |
| 2183 | 2181 |
| 2184 TEST_F(ExtensionUpdaterTest, TestStartUpdateCheckMemory) { | 2182 TEST_F(ExtensionUpdaterTest, TestStartUpdateCheckMemory) { |
| 2185 net::TestURLFetcherFactory factory; | 2183 net::TestURLFetcherFactory factory; |
| 2186 MockService service(prefs_.get()); | 2184 MockService service(prefs_.get()); |
| 2187 MockExtensionDownloaderDelegate delegate; | 2185 MockExtensionDownloaderDelegate delegate; |
| 2188 ExtensionDownloader downloader(&delegate, service.request_context()); | 2186 ExtensionDownloader downloader(&delegate, service.request_context()); |
| 2189 | 2187 |
| 2190 StartUpdateCheck(&downloader, CreateManifestFetchData(GURL("http://localhost/f
oo"))); | 2188 StartUpdateCheck(&downloader, |
| 2189 CreateManifestFetchData(GURL("http://localhost/foo"))); |
| 2191 // This should delete the newly-created ManifestFetchData. | 2190 // This should delete the newly-created ManifestFetchData. |
| 2192 StartUpdateCheck(&downloader, CreateManifestFetchData(GURL("http://localhost/f
oo"))); | 2191 StartUpdateCheck(&downloader, |
| 2192 CreateManifestFetchData(GURL("http://localhost/foo"))); |
| 2193 // This should add into |manifests_pending_|. | 2193 // This should add into |manifests_pending_|. |
| 2194 StartUpdateCheck(&downloader, | 2194 StartUpdateCheck(&downloader, |
| 2195 CreateManifestFetchData(GURL("http://www.google.com"))); | 2195 CreateManifestFetchData(GURL("http://www.google.com"))); |
| 2196 // The dtor of |downloader| should delete the pending fetchers. | 2196 // The dtor of |downloader| should delete the pending fetchers. |
| 2197 } | 2197 } |
| 2198 | 2198 |
| 2199 TEST_F(ExtensionUpdaterTest, TestCheckSoon) { | 2199 TEST_F(ExtensionUpdaterTest, TestCheckSoon) { |
| 2200 ServiceForManifestTests service(prefs_.get()); | 2200 ServiceForManifestTests service(prefs_.get()); |
| 2201 net::TestURLFetcherFactory factory; | 2201 net::TestURLFetcherFactory factory; |
| 2202 ExtensionUpdater updater(&service, | 2202 ExtensionUpdater updater(&service, |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2244 // -prodversionmin (shouldn't update if browser version too old) | 2244 // -prodversionmin (shouldn't update if browser version too old) |
| 2245 // -manifests & updates arriving out of order / interleaved | 2245 // -manifests & updates arriving out of order / interleaved |
| 2246 // -malformed update url (empty, file://, has query, has a # fragment, etc.) | 2246 // -malformed update url (empty, file://, has query, has a # fragment, etc.) |
| 2247 // -An extension gets uninstalled while updates are in progress (so it doesn't | 2247 // -An extension gets uninstalled while updates are in progress (so it doesn't |
| 2248 // "come back from the dead") | 2248 // "come back from the dead") |
| 2249 // -An extension gets manually updated to v3 while we're downloading v2 (ie | 2249 // -An extension gets manually updated to v3 while we're downloading v2 (ie |
| 2250 // you don't get downgraded accidentally) | 2250 // you don't get downgraded accidentally) |
| 2251 // -An update manifest mentions multiple updates | 2251 // -An update manifest mentions multiple updates |
| 2252 | 2252 |
| 2253 } // namespace extensions | 2253 } // namespace extensions |
| OLD | NEW |