| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 #include "chrome/common/extensions/extension.h" | 43 #include "chrome/common/extensions/extension.h" |
| 44 #include "chrome/common/extensions/extension_manifest_constants.h" | 44 #include "chrome/common/extensions/extension_manifest_constants.h" |
| 45 #include "chrome/common/omaha_query_params/omaha_query_params.h" | 45 #include "chrome/common/omaha_query_params/omaha_query_params.h" |
| 46 #include "chrome/common/pref_names.h" | 46 #include "chrome/common/pref_names.h" |
| 47 #include "chrome/test/base/testing_profile.h" | 47 #include "chrome/test/base/testing_profile.h" |
| 48 #include "content/public/browser/notification_details.h" | 48 #include "content/public/browser/notification_details.h" |
| 49 #include "content/public/browser/notification_observer.h" | 49 #include "content/public/browser/notification_observer.h" |
| 50 #include "content/public/browser/notification_registrar.h" | 50 #include "content/public/browser/notification_registrar.h" |
| 51 #include "content/public/browser/notification_service.h" | 51 #include "content/public/browser/notification_service.h" |
| 52 #include "content/public/browser/notification_source.h" | 52 #include "content/public/browser/notification_source.h" |
| 53 #include "content/public/test/test_browser_thread.h" | 53 #include "content/public/browser/render_process_host.h" |
| 54 #include "content/public/test/test_browser_thread_bundle.h" |
| 55 #include "content/public/test/test_utils.h" |
| 54 #include "extensions/common/id_util.h" | 56 #include "extensions/common/id_util.h" |
| 55 #include "libxml/globals.h" | 57 #include "libxml/globals.h" |
| 56 #include "net/base/backoff_entry.h" | 58 #include "net/base/backoff_entry.h" |
| 57 #include "net/base/escape.h" | 59 #include "net/base/escape.h" |
| 58 #include "net/base/load_flags.h" | 60 #include "net/base/load_flags.h" |
| 59 #include "net/url_request/test_url_fetcher_factory.h" | 61 #include "net/url_request/test_url_fetcher_factory.h" |
| 60 #include "net/url_request/url_request_status.h" | 62 #include "net/url_request/url_request_status.h" |
| 61 #include "testing/gmock/include/gmock/gmock.h" | 63 #include "testing/gmock/include/gmock/gmock.h" |
| 62 #include "testing/gtest/include/gtest/gtest.h" | 64 #include "testing/gtest/include/gtest/gtest.h" |
| 63 | 65 |
| 64 #if defined(OS_CHROMEOS) | 66 #if defined(OS_CHROMEOS) |
| 65 #include "chrome/browser/chromeos/login/user_manager.h" | 67 #include "chrome/browser/chromeos/login/user_manager.h" |
| 66 #include "chrome/browser/chromeos/settings/cros_settings.h" | 68 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 67 #include "chrome/browser/chromeos/settings/device_settings_service.h" | 69 #include "chrome/browser/chromeos/settings/device_settings_service.h" |
| 68 #endif | 70 #endif |
| 69 | 71 |
| 70 using base::Time; | 72 using base::Time; |
| 71 using base::TimeDelta; | 73 using base::TimeDelta; |
| 72 using content::BrowserThread; | 74 using content::BrowserThread; |
| 73 using testing::DoAll; | 75 using testing::DoAll; |
| 76 using testing::InvokeWithoutArgs; |
| 74 using testing::Mock; | 77 using testing::Mock; |
| 75 using testing::Return; | 78 using testing::Return; |
| 76 using testing::SetArgPointee; | 79 using testing::SetArgPointee; |
| 77 using testing::_; | 80 using testing::_; |
| 78 | 81 |
| 79 namespace extensions { | 82 namespace extensions { |
| 80 | 83 |
| 81 typedef ExtensionDownloaderDelegate::Error Error; | 84 typedef ExtensionDownloaderDelegate::Error Error; |
| 82 typedef ExtensionDownloaderDelegate::PingResult PingResult; | 85 typedef ExtensionDownloaderDelegate::PingResult PingResult; |
| 83 | 86 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 const std::string&, | 138 const std::string&, |
| 136 const std::string&, | 139 const std::string&, |
| 137 const PingResult&, | 140 const PingResult&, |
| 138 const std::set<int>&)); | 141 const std::set<int>&)); |
| 139 MOCK_METHOD2(GetPingDataForExtension, | 142 MOCK_METHOD2(GetPingDataForExtension, |
| 140 bool(const std::string&, ManifestFetchData::PingData*)); | 143 bool(const std::string&, ManifestFetchData::PingData*)); |
| 141 MOCK_METHOD1(GetUpdateUrlData, std::string(const std::string&)); | 144 MOCK_METHOD1(GetUpdateUrlData, std::string(const std::string&)); |
| 142 MOCK_METHOD1(IsExtensionPending, bool(const std::string&)); | 145 MOCK_METHOD1(IsExtensionPending, bool(const std::string&)); |
| 143 MOCK_METHOD2(GetExtensionExistingVersion, | 146 MOCK_METHOD2(GetExtensionExistingVersion, |
| 144 bool(const std::string&, std::string*)); | 147 bool(const std::string&, std::string*)); |
| 148 |
| 149 void Wait() { |
| 150 scoped_refptr<content::MessageLoopRunner> runner = |
| 151 new content::MessageLoopRunner; |
| 152 quit_closure_ = runner->QuitClosure(); |
| 153 runner->Run(); |
| 154 quit_closure_.Reset(); |
| 155 } |
| 156 |
| 157 void Quit() { |
| 158 quit_closure_.Run(); |
| 159 } |
| 160 |
| 161 private: |
| 162 base::Closure quit_closure_; |
| 145 }; | 163 }; |
| 146 | 164 |
| 147 const int kNotificationsObserved[] = { | 165 const int kNotificationsObserved[] = { |
| 148 chrome::NOTIFICATION_EXTENSION_UPDATING_STARTED, | 166 chrome::NOTIFICATION_EXTENSION_UPDATING_STARTED, |
| 149 chrome::NOTIFICATION_EXTENSION_UPDATE_FOUND, | 167 chrome::NOTIFICATION_EXTENSION_UPDATE_FOUND, |
| 150 }; | 168 }; |
| 151 | 169 |
| 152 // A class that observes the notifications sent by the ExtensionUpdater and | 170 // A class that observes the notifications sent by the ExtensionUpdater and |
| 153 // the ExtensionDownloader. | 171 // the ExtensionDownloader. |
| 154 class NotificationsObserver : public content::NotificationObserver { | 172 class NotificationsObserver : public content::NotificationObserver { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 170 } | 188 } |
| 171 } | 189 } |
| 172 | 190 |
| 173 size_t StartedCount() { return count_[0]; } | 191 size_t StartedCount() { return count_[0]; } |
| 174 size_t UpdatedCount() { return count_[1]; } | 192 size_t UpdatedCount() { return count_[1]; } |
| 175 | 193 |
| 176 bool Updated(const std::string& id) { | 194 bool Updated(const std::string& id) { |
| 177 return updated_.find(id) != updated_.end(); | 195 return updated_.find(id) != updated_.end(); |
| 178 } | 196 } |
| 179 | 197 |
| 198 void Wait() { |
| 199 scoped_refptr<content::MessageLoopRunner> runner = |
| 200 new content::MessageLoopRunner; |
| 201 quit_closure_ = runner->QuitClosure(); |
| 202 runner->Run(); |
| 203 quit_closure_.Reset(); |
| 204 } |
| 205 |
| 180 private: | 206 private: |
| 181 virtual void Observe(int type, | 207 virtual void Observe(int type, |
| 182 const content::NotificationSource& source, | 208 const content::NotificationSource& source, |
| 183 const content::NotificationDetails& details) OVERRIDE { | 209 const content::NotificationDetails& details) OVERRIDE { |
| 210 if (!quit_closure_.is_null()) |
| 211 quit_closure_.Run(); |
| 184 for (size_t i = 0; i < arraysize(kNotificationsObserved); ++i) { | 212 for (size_t i = 0; i < arraysize(kNotificationsObserved); ++i) { |
| 185 if (kNotificationsObserved[i] == type) { | 213 if (kNotificationsObserved[i] == type) { |
| 186 count_[i]++; | 214 count_[i]++; |
| 187 if (type == chrome::NOTIFICATION_EXTENSION_UPDATE_FOUND) { | 215 if (type == chrome::NOTIFICATION_EXTENSION_UPDATE_FOUND) { |
| 188 updated_.insert( | 216 updated_.insert( |
| 189 content::Details<UpdateDetails>(details)->id); | 217 content::Details<UpdateDetails>(details)->id); |
| 190 } | 218 } |
| 191 return; | 219 return; |
| 192 } | 220 } |
| 193 } | 221 } |
| 194 NOTREACHED(); | 222 NOTREACHED(); |
| 195 } | 223 } |
| 196 | 224 |
| 197 content::NotificationRegistrar registrar_; | 225 content::NotificationRegistrar registrar_; |
| 198 size_t count_[arraysize(kNotificationsObserved)]; | 226 size_t count_[arraysize(kNotificationsObserved)]; |
| 199 std::set<std::string> updated_; | 227 std::set<std::string> updated_; |
| 228 base::Closure quit_closure_; |
| 200 | 229 |
| 201 DISALLOW_COPY_AND_ASSIGN(NotificationsObserver); | 230 DISALLOW_COPY_AND_ASSIGN(NotificationsObserver); |
| 202 }; | 231 }; |
| 203 | 232 |
| 204 } // namespace | 233 } // namespace |
| 205 | 234 |
| 206 // Base class for further specialized test classes. | 235 // Base class for further specialized test classes. |
| 207 class MockService : public TestExtensionService { | 236 class MockService : public TestExtensionService { |
| 208 public: | 237 public: |
| 209 explicit MockService(TestExtensionPrefs* prefs) | 238 explicit MockService(TestExtensionPrefs* prefs) |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 std::string decoded = net::UnescapeURLComponent( | 491 std::string decoded = net::UnescapeURLComponent( |
| 463 params["x"], net::UnescapeRule::URL_SPECIAL_CHARS); | 492 params["x"], net::UnescapeRule::URL_SPECIAL_CHARS); |
| 464 ExtractParameters(decoded, result); | 493 ExtractParameters(decoded, result); |
| 465 } | 494 } |
| 466 | 495 |
| 467 // All of our tests that need to use private APIs of ExtensionUpdater live | 496 // All of our tests that need to use private APIs of ExtensionUpdater live |
| 468 // inside this class (which is a friend to ExtensionUpdater). | 497 // inside this class (which is a friend to ExtensionUpdater). |
| 469 class ExtensionUpdaterTest : public testing::Test { | 498 class ExtensionUpdaterTest : public testing::Test { |
| 470 public: | 499 public: |
| 471 ExtensionUpdaterTest() | 500 ExtensionUpdaterTest() |
| 472 : ui_thread_(BrowserThread::UI, &loop_), | 501 : test_browser_thread_bundle_( |
| 473 file_thread_(BrowserThread::FILE, &loop_), | 502 content::TestBrowserThreadBundle::IO_MAINLOOP) { |
| 474 io_thread_(BrowserThread::IO, &loop_) { | |
| 475 } | 503 } |
| 476 | 504 |
| 477 virtual ~ExtensionUpdaterTest() { | 505 virtual ~ExtensionUpdaterTest() { |
| 478 } | 506 } |
| 479 | 507 |
| 480 virtual void SetUp() OVERRIDE { | 508 virtual void SetUp() OVERRIDE { |
| 481 prefs_.reset(new TestExtensionPrefs(loop_.message_loop_proxy().get())); | 509 prefs_.reset(new TestExtensionPrefs(base::MessageLoopProxy::current())); |
| 510 content::RenderProcessHost::SetRunRendererInProcess(true); |
| 482 } | 511 } |
| 483 | 512 |
| 484 virtual void TearDown() OVERRIDE { | 513 virtual void TearDown() OVERRIDE { |
| 485 // Some tests create URLRequestContextGetters, whose destruction must run | 514 // Some tests create URLRequestContextGetters, whose destruction must run |
| 486 // on the IO thread. Make sure the IO loop spins before shutdown so that | 515 // on the IO thread. Make sure the IO loop spins before shutdown so that |
| 487 // those objects are released. | 516 // those objects are released. |
| 488 RunUntilIdle(); | 517 RunUntilIdle(); |
| 489 prefs_.reset(); | 518 prefs_.reset(); |
| 519 content::RenderProcessHost::SetRunRendererInProcess(false); |
| 490 } | 520 } |
| 491 | 521 |
| 492 void RunUntilIdle() { | 522 void RunUntilIdle() { |
| 493 prefs_->pref_service()->CommitPendingWrite(); | 523 prefs_->pref_service()->CommitPendingWrite(); |
| 494 loop_.RunUntilIdle(); | 524 base::RunLoop().RunUntilIdle(); |
| 495 } | 525 } |
| 496 | 526 |
| 497 void SimulateTimerFired(ExtensionUpdater* updater) { | 527 void SimulateTimerFired(ExtensionUpdater* updater) { |
| 498 EXPECT_TRUE(updater->timer_.IsRunning()); | 528 EXPECT_TRUE(updater->timer_.IsRunning()); |
| 499 updater->timer_.Stop(); | 529 updater->timer_.Stop(); |
| 500 updater->TimerFired(); | 530 updater->TimerFired(); |
| 501 } | 531 } |
| 502 | 532 |
| 503 // Adds a Result with the given data to results. | 533 // Adds a Result with the given data to results. |
| 504 void AddParseResult(const std::string& id, | 534 void AddParseResult(const std::string& id, |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 845 fetcher->delegate()->OnURLFetchComplete(fetcher); | 875 fetcher->delegate()->OnURLFetchComplete(fetcher); |
| 846 RunUntilIdle(); | 876 RunUntilIdle(); |
| 847 Mock::VerifyAndClearExpectations(&delegate); | 877 Mock::VerifyAndClearExpectations(&delegate); |
| 848 | 878 |
| 849 // The second fetch gets invalid data. | 879 // The second fetch gets invalid data. |
| 850 const std::string kInvalidXml = "invalid xml"; | 880 const std::string kInvalidXml = "invalid xml"; |
| 851 fetcher = factory.GetFetcherByID(ExtensionDownloader::kManifestFetcherId); | 881 fetcher = factory.GetFetcherByID(ExtensionDownloader::kManifestFetcherId); |
| 852 EXPECT_TRUE(fetcher != NULL && fetcher->delegate() != NULL); | 882 EXPECT_TRUE(fetcher != NULL && fetcher->delegate() != NULL); |
| 853 EXPECT_TRUE(fetcher->GetLoadFlags() == kExpectedLoadFlags); | 883 EXPECT_TRUE(fetcher->GetLoadFlags() == kExpectedLoadFlags); |
| 854 EXPECT_CALL(delegate, OnExtensionDownloadFailed( | 884 EXPECT_CALL(delegate, OnExtensionDownloadFailed( |
| 855 "2222", ExtensionDownloaderDelegate::MANIFEST_INVALID, _, _)); | 885 "2222", ExtensionDownloaderDelegate::MANIFEST_INVALID, _, _)) |
| 886 .WillOnce(InvokeWithoutArgs(&delegate, |
| 887 &MockExtensionDownloaderDelegate::Quit)); |
| 856 fetcher->set_url(kUpdateUrl); | 888 fetcher->set_url(kUpdateUrl); |
| 857 fetcher->set_status(net::URLRequestStatus()); | 889 fetcher->set_status(net::URLRequestStatus()); |
| 858 fetcher->set_response_code(200); | 890 fetcher->set_response_code(200); |
| 859 fetcher->SetResponseString(kInvalidXml); | 891 fetcher->SetResponseString(kInvalidXml); |
| 860 fetcher->delegate()->OnURLFetchComplete(fetcher); | 892 fetcher->delegate()->OnURLFetchComplete(fetcher); |
| 861 RunUntilIdle(); | 893 delegate.Wait(); |
| 862 Mock::VerifyAndClearExpectations(&delegate); | 894 Mock::VerifyAndClearExpectations(&delegate); |
| 863 | 895 |
| 864 // The third fetcher doesn't have an update available. | 896 // The third fetcher doesn't have an update available. |
| 865 const std::string kNoUpdate = | 897 const std::string kNoUpdate = |
| 866 "<?xml version='1.0' encoding='UTF-8'?>" | 898 "<?xml version='1.0' encoding='UTF-8'?>" |
| 867 "<gupdate xmlns='http://www.google.com/update2/response'" | 899 "<gupdate xmlns='http://www.google.com/update2/response'" |
| 868 " protocol='2.0'>" | 900 " protocol='2.0'>" |
| 869 " <app appid='3333'>" | 901 " <app appid='3333'>" |
| 870 " <updatecheck codebase='http://example.com/extension_3.0.0.0.crx'" | 902 " <updatecheck codebase='http://example.com/extension_3.0.0.0.crx'" |
| 871 " version='3.0.0.0' prodversionmin='3.0.0.0' />" | 903 " version='3.0.0.0' prodversionmin='3.0.0.0' />" |
| 872 " </app>" | 904 " </app>" |
| 873 "</gupdate>"; | 905 "</gupdate>"; |
| 874 fetcher = factory.GetFetcherByID(ExtensionDownloader::kManifestFetcherId); | 906 fetcher = factory.GetFetcherByID(ExtensionDownloader::kManifestFetcherId); |
| 875 EXPECT_TRUE(fetcher != NULL && fetcher->delegate() != NULL); | 907 EXPECT_TRUE(fetcher != NULL && fetcher->delegate() != NULL); |
| 876 EXPECT_TRUE(fetcher->GetLoadFlags() == kExpectedLoadFlags); | 908 EXPECT_TRUE(fetcher->GetLoadFlags() == kExpectedLoadFlags); |
| 877 EXPECT_CALL(delegate, IsExtensionPending("3333")).WillOnce(Return(false)); | 909 EXPECT_CALL(delegate, IsExtensionPending("3333")).WillOnce(Return(false)); |
| 878 EXPECT_CALL(delegate, GetExtensionExistingVersion("3333", _)) | 910 EXPECT_CALL(delegate, GetExtensionExistingVersion("3333", _)) |
| 879 .WillOnce(DoAll(SetArgPointee<1>("3.0.0.0"), | 911 .WillOnce(DoAll(SetArgPointee<1>("3.0.0.0"), |
| 880 Return(true))); | 912 Return(true))); |
| 881 EXPECT_CALL(delegate, OnExtensionDownloadFailed( | 913 EXPECT_CALL(delegate, OnExtensionDownloadFailed( |
| 882 "3333", ExtensionDownloaderDelegate::NO_UPDATE_AVAILABLE, _, _)); | 914 "3333", ExtensionDownloaderDelegate::NO_UPDATE_AVAILABLE, _, _)) |
| 915 .WillOnce(InvokeWithoutArgs(&delegate, |
| 916 &MockExtensionDownloaderDelegate::Quit)); |
| 883 fetcher->set_url(kUpdateUrl); | 917 fetcher->set_url(kUpdateUrl); |
| 884 fetcher->set_status(net::URLRequestStatus()); | 918 fetcher->set_status(net::URLRequestStatus()); |
| 885 fetcher->set_response_code(200); | 919 fetcher->set_response_code(200); |
| 886 fetcher->SetResponseString(kNoUpdate); | 920 fetcher->SetResponseString(kNoUpdate); |
| 887 fetcher->delegate()->OnURLFetchComplete(fetcher); | 921 fetcher->delegate()->OnURLFetchComplete(fetcher); |
| 888 RunUntilIdle(); | 922 delegate.Wait(); |
| 889 Mock::VerifyAndClearExpectations(&delegate); | 923 Mock::VerifyAndClearExpectations(&delegate); |
| 890 | 924 |
| 891 // The last fetcher has an update. | 925 // The last fetcher has an update. |
| 892 const std::string kUpdateAvailable = | 926 const std::string kUpdateAvailable = |
| 893 "<?xml version='1.0' encoding='UTF-8'?>" | 927 "<?xml version='1.0' encoding='UTF-8'?>" |
| 894 "<gupdate xmlns='http://www.google.com/update2/response'" | 928 "<gupdate xmlns='http://www.google.com/update2/response'" |
| 895 " protocol='2.0'>" | 929 " protocol='2.0'>" |
| 896 " <app appid='4444'>" | 930 " <app appid='4444'>" |
| 897 " <updatecheck codebase='http://example.com/extension_1.2.3.4.crx'" | 931 " <updatecheck codebase='http://example.com/extension_1.2.3.4.crx'" |
| 898 " version='4.0.42.0' prodversionmin='4.0.42.0' />" | 932 " version='4.0.42.0' prodversionmin='4.0.42.0' />" |
| 899 " </app>" | 933 " </app>" |
| 900 "</gupdate>"; | 934 "</gupdate>"; |
| 901 fetcher = factory.GetFetcherByID(ExtensionDownloader::kManifestFetcherId); | 935 fetcher = factory.GetFetcherByID(ExtensionDownloader::kManifestFetcherId); |
| 902 EXPECT_TRUE(fetcher != NULL && fetcher->delegate() != NULL); | 936 EXPECT_TRUE(fetcher != NULL && fetcher->delegate() != NULL); |
| 903 EXPECT_TRUE(fetcher->GetLoadFlags() == kExpectedLoadFlags); | 937 EXPECT_TRUE(fetcher->GetLoadFlags() == kExpectedLoadFlags); |
| 904 EXPECT_CALL(delegate, IsExtensionPending("4444")).WillOnce(Return(false)); | 938 EXPECT_CALL(delegate, IsExtensionPending("4444")).WillOnce(Return(false)); |
| 905 EXPECT_CALL(delegate, GetExtensionExistingVersion("4444", _)) | 939 EXPECT_CALL(delegate, GetExtensionExistingVersion("4444", _)) |
| 906 .WillOnce(DoAll(SetArgPointee<1>("4.0.0.0"), | 940 .WillOnce(DoAll(SetArgPointee<1>("4.0.0.0"), |
| 907 Return(true))); | 941 Return(true))); |
| 908 fetcher->set_url(kUpdateUrl); | 942 fetcher->set_url(kUpdateUrl); |
| 909 fetcher->set_status(net::URLRequestStatus()); | 943 fetcher->set_status(net::URLRequestStatus()); |
| 910 fetcher->set_response_code(200); | 944 fetcher->set_response_code(200); |
| 911 fetcher->SetResponseString(kUpdateAvailable); | 945 fetcher->SetResponseString(kUpdateAvailable); |
| 912 fetcher->delegate()->OnURLFetchComplete(fetcher); | 946 fetcher->delegate()->OnURLFetchComplete(fetcher); |
| 913 RunUntilIdle(); | 947 observer.Wait(); |
| 914 Mock::VerifyAndClearExpectations(&delegate); | 948 Mock::VerifyAndClearExpectations(&delegate); |
| 915 | 949 |
| 916 // Verify that the downloader decided to update this extension. | 950 // Verify that the downloader decided to update this extension. |
| 917 EXPECT_EQ(1u, observer.UpdatedCount()); | 951 EXPECT_EQ(1u, observer.UpdatedCount()); |
| 918 EXPECT_TRUE(observer.Updated("4444")); | 952 EXPECT_TRUE(observer.Updated("4444")); |
| 919 } | 953 } |
| 920 | 954 |
| 921 void TestManifestRetryDownloading() { | 955 void TestManifestRetryDownloading() { |
| 922 net::TestURLFetcherFactory factory; | 956 net::TestURLFetcherFactory factory; |
| 923 net::TestURLFetcher* fetcher = NULL; | 957 net::TestURLFetcher* fetcher = NULL; |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1301 // on the delta between now and the last ping time (or in the case of active | 1335 // on the delta between now and the last ping time (or in the case of active |
| 1302 // pings, that delta plus whether the app has been active). | 1336 // pings, that delta plus whether the app has been active). |
| 1303 void TestGalleryRequests(int rollcall_ping_days, | 1337 void TestGalleryRequests(int rollcall_ping_days, |
| 1304 int active_ping_days, | 1338 int active_ping_days, |
| 1305 bool active_bit, | 1339 bool active_bit, |
| 1306 bool expect_brand_code) { | 1340 bool expect_brand_code) { |
| 1307 net::TestURLFetcherFactory factory; | 1341 net::TestURLFetcherFactory factory; |
| 1308 | 1342 |
| 1309 // Set up 2 mock extensions, one with a google.com update url and one | 1343 // Set up 2 mock extensions, one with a google.com update url and one |
| 1310 // without. | 1344 // without. |
| 1311 prefs_.reset(new TestExtensionPrefs(loop_.message_loop_proxy().get())); | 1345 prefs_.reset(new TestExtensionPrefs(base::MessageLoopProxy::current())); |
| 1312 ServiceForManifestTests service(prefs_.get()); | 1346 ServiceForManifestTests service(prefs_.get()); |
| 1313 ExtensionList tmp; | 1347 ExtensionList tmp; |
| 1314 GURL url1("http://clients2.google.com/service/update2/crx"); | 1348 GURL url1("http://clients2.google.com/service/update2/crx"); |
| 1315 GURL url2("http://www.somewebsite.com"); | 1349 GURL url2("http://www.somewebsite.com"); |
| 1316 service.CreateTestExtensions(1, 1, &tmp, &url1.possibly_invalid_spec(), | 1350 service.CreateTestExtensions(1, 1, &tmp, &url1.possibly_invalid_spec(), |
| 1317 Manifest::INTERNAL); | 1351 Manifest::INTERNAL); |
| 1318 service.CreateTestExtensions(2, 1, &tmp, &url2.possibly_invalid_spec(), | 1352 service.CreateTestExtensions(2, 1, &tmp, &url2.possibly_invalid_spec(), |
| 1319 Manifest::INTERNAL); | 1353 Manifest::INTERNAL); |
| 1320 EXPECT_EQ(2u, tmp.size()); | 1354 EXPECT_EQ(2u, tmp.size()); |
| 1321 service.set_extensions(tmp); | 1355 service.set_extensions(tmp); |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1461 service.extension_prefs()->LastPingDay(extension->id()); | 1495 service.extension_prefs()->LastPingDay(extension->id()); |
| 1462 EXPECT_FALSE(last_ping_day.is_null()); | 1496 EXPECT_FALSE(last_ping_day.is_null()); |
| 1463 int64 seconds_diff = (Time::Now() - last_ping_day).InSeconds(); | 1497 int64 seconds_diff = (Time::Now() - last_ping_day).InSeconds(); |
| 1464 EXPECT_LT(seconds_diff - results.daystart_elapsed_seconds, 5); | 1498 EXPECT_LT(seconds_diff - results.daystart_elapsed_seconds, 5); |
| 1465 } | 1499 } |
| 1466 | 1500 |
| 1467 protected: | 1501 protected: |
| 1468 scoped_ptr<TestExtensionPrefs> prefs_; | 1502 scoped_ptr<TestExtensionPrefs> prefs_; |
| 1469 | 1503 |
| 1470 private: | 1504 private: |
| 1471 base::MessageLoop loop_; | 1505 content::TestBrowserThreadBundle test_browser_thread_bundle_; |
| 1472 content::TestBrowserThread ui_thread_; | |
| 1473 content::TestBrowserThread file_thread_; | |
| 1474 content::TestBrowserThread io_thread_; | |
| 1475 | 1506 |
| 1476 #if defined OS_CHROMEOS | 1507 #if defined OS_CHROMEOS |
| 1477 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; | 1508 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; |
| 1478 chromeos::ScopedTestCrosSettings test_cros_settings_; | 1509 chromeos::ScopedTestCrosSettings test_cros_settings_; |
| 1479 chromeos::ScopedTestUserManager test_user_manager_; | 1510 chromeos::ScopedTestUserManager test_user_manager_; |
| 1480 #endif | 1511 #endif |
| 1481 }; | 1512 }; |
| 1482 | 1513 |
| 1483 // Because we test some private methods of ExtensionUpdater, it's easier for the | 1514 // Because we test some private methods of ExtensionUpdater, it's easier for the |
| 1484 // actual test code to live in ExtenionUpdaterTest methods instead of TEST_F | 1515 // actual test code to live in ExtenionUpdaterTest methods instead of TEST_F |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1728 // -prodversionmin (shouldn't update if browser version too old) | 1759 // -prodversionmin (shouldn't update if browser version too old) |
| 1729 // -manifests & updates arriving out of order / interleaved | 1760 // -manifests & updates arriving out of order / interleaved |
| 1730 // -malformed update url (empty, file://, has query, has a # fragment, etc.) | 1761 // -malformed update url (empty, file://, has query, has a # fragment, etc.) |
| 1731 // -An extension gets uninstalled while updates are in progress (so it doesn't | 1762 // -An extension gets uninstalled while updates are in progress (so it doesn't |
| 1732 // "come back from the dead") | 1763 // "come back from the dead") |
| 1733 // -An extension gets manually updated to v3 while we're downloading v2 (ie | 1764 // -An extension gets manually updated to v3 while we're downloading v2 (ie |
| 1734 // you don't get downgraded accidentally) | 1765 // you don't get downgraded accidentally) |
| 1735 // -An update manifest mentions multiple updates | 1766 // -An update manifest mentions multiple updates |
| 1736 | 1767 |
| 1737 } // namespace extensions | 1768 } // namespace extensions |
| OLD | NEW |