| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <map> | 5 #include <map> |
| 6 | 6 |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/stl_util-inl.h" | 10 #include "base/stl_util-inl.h" |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 // All of our tests that need to use private APIs of ExtensionUpdater live | 263 // All of our tests that need to use private APIs of ExtensionUpdater live |
| 264 // inside this class (which is a friend to ExtensionUpdater). | 264 // inside this class (which is a friend to ExtensionUpdater). |
| 265 class ExtensionUpdaterTest : public testing::Test { | 265 class ExtensionUpdaterTest : public testing::Test { |
| 266 public: | 266 public: |
| 267 static void SimulateTimerFired(ExtensionUpdater* updater) { | 267 static void SimulateTimerFired(ExtensionUpdater* updater) { |
| 268 EXPECT_TRUE(updater->timer_.IsRunning()); | 268 EXPECT_TRUE(updater->timer_.IsRunning()); |
| 269 updater->timer_.Stop(); | 269 updater->timer_.Stop(); |
| 270 updater->TimerFired(); | 270 updater->TimerFired(); |
| 271 } | 271 } |
| 272 | 272 |
| 273 static void SimulateCheckSoon(ExtensionUpdater* updater) { | 273 static void SimulateCheckSoon(const ExtensionUpdater& updater, |
| 274 EXPECT_TRUE(updater->will_check_soon_); | 274 MessageLoop* message_loop) { |
| 275 updater->DoCheckSoon(); | 275 EXPECT_TRUE(updater.will_check_soon_); |
| 276 message_loop->RunAllPending(); |
| 276 } | 277 } |
| 277 | 278 |
| 278 // Adds a Result with the given data to results. | 279 // Adds a Result with the given data to results. |
| 279 static void AddParseResult( | 280 static void AddParseResult( |
| 280 const std::string& id, | 281 const std::string& id, |
| 281 const std::string& version, | 282 const std::string& version, |
| 282 const std::string& url, | 283 const std::string& url, |
| 283 UpdateManifest::Results* results) { | 284 UpdateManifest::Results* results) { |
| 284 UpdateManifest::Result result; | 285 UpdateManifest::Result result; |
| 285 result.extension_id = id; | 286 result.extension_id = id; |
| (...skipping 840 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1126 ExtensionUpdater updater( | 1127 ExtensionUpdater updater( |
| 1127 &service, service.extension_prefs(), service.pref_service(), | 1128 &service, service.extension_prefs(), service.pref_service(), |
| 1128 service.profile(), kUpdateFrequencySecs); | 1129 service.profile(), kUpdateFrequencySecs); |
| 1129 EXPECT_FALSE(updater.WillCheckSoon()); | 1130 EXPECT_FALSE(updater.WillCheckSoon()); |
| 1130 updater.Start(); | 1131 updater.Start(); |
| 1131 EXPECT_FALSE(updater.WillCheckSoon()); | 1132 EXPECT_FALSE(updater.WillCheckSoon()); |
| 1132 updater.CheckSoon(); | 1133 updater.CheckSoon(); |
| 1133 EXPECT_TRUE(updater.WillCheckSoon()); | 1134 EXPECT_TRUE(updater.WillCheckSoon()); |
| 1134 updater.CheckSoon(); | 1135 updater.CheckSoon(); |
| 1135 EXPECT_TRUE(updater.WillCheckSoon()); | 1136 EXPECT_TRUE(updater.WillCheckSoon()); |
| 1136 ExtensionUpdaterTest::SimulateCheckSoon(&updater); | 1137 ExtensionUpdaterTest::SimulateCheckSoon(updater, &message_loop); |
| 1137 EXPECT_FALSE(updater.WillCheckSoon()); | 1138 EXPECT_FALSE(updater.WillCheckSoon()); |
| 1138 updater.CheckSoon(); | 1139 updater.CheckSoon(); |
| 1139 EXPECT_TRUE(updater.WillCheckSoon()); | 1140 EXPECT_TRUE(updater.WillCheckSoon()); |
| 1140 updater.Stop(); | 1141 updater.Stop(); |
| 1141 EXPECT_FALSE(updater.WillCheckSoon()); | 1142 EXPECT_FALSE(updater.WillCheckSoon()); |
| 1142 } | 1143 } |
| 1143 | 1144 |
| 1144 // TODO(asargent) - (http://crbug.com/12780) add tests for: | 1145 // TODO(asargent) - (http://crbug.com/12780) add tests for: |
| 1145 // -prodversionmin (shouldn't update if browser version too old) | 1146 // -prodversionmin (shouldn't update if browser version too old) |
| 1146 // -manifests & updates arriving out of order / interleaved | 1147 // -manifests & updates arriving out of order / interleaved |
| 1147 // -malformed update url (empty, file://, has query, has a # fragment, etc.) | 1148 // -malformed update url (empty, file://, has query, has a # fragment, etc.) |
| 1148 // -An extension gets uninstalled while updates are in progress (so it doesn't | 1149 // -An extension gets uninstalled while updates are in progress (so it doesn't |
| 1149 // "come back from the dead") | 1150 // "come back from the dead") |
| 1150 // -An extension gets manually updated to v3 while we're downloading v2 (ie | 1151 // -An extension gets manually updated to v3 while we're downloading v2 (ie |
| 1151 // you don't get downgraded accidentally) | 1152 // you don't get downgraded accidentally) |
| 1152 // -An update manifest mentions multiple updates | 1153 // -An update manifest mentions multiple updates |
| OLD | NEW |