| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/file_util.h" | 5 #include "base/file_util.h" |
| 6 #include "base/string_util.h" | 6 #include "base/string_util.h" |
| 7 #include "chrome/browser/extensions/extension_updater.h" | 7 #include "chrome/browser/extensions/extension_updater.h" |
| 8 #include "chrome/browser/extensions/extensions_service.h" | 8 #include "chrome/browser/extensions/extensions_service.h" |
| 9 #include "chrome/browser/net/test_url_fetcher_factory.h" | 9 #include "chrome/browser/net/test_url_fetcher_factory.h" |
| 10 #include "chrome/common/extensions/extension.h" | 10 #include "chrome/common/extensions/extension.h" |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 scoped_ptr<Version> one(Version::GetVersionFromString("1.0")); | 262 scoped_ptr<Version> one(Version::GetVersionFromString("1.0")); |
| 263 EXPECT_TRUE(tmp[0]->version()->Equals(*one)); | 263 EXPECT_TRUE(tmp[0]->version()->Equals(*one)); |
| 264 updates.push_back(MakeParseResult(tmp[0]->id(), | 264 updates.push_back(MakeParseResult(tmp[0]->id(), |
| 265 "1.1", "http://localhost/e1_1.1.crx")); | 265 "1.1", "http://localhost/e1_1.1.crx")); |
| 266 updates.push_back(MakeParseResult(tmp[1]->id(), | 266 updates.push_back(MakeParseResult(tmp[1]->id(), |
| 267 tmp[1]->VersionString(), "http://localhost/e2_2.0.crx")); | 267 tmp[1]->VersionString(), "http://localhost/e2_2.0.crx")); |
| 268 updateable = updater->DetermineUpdates(updates); | 268 updateable = updater->DetermineUpdates(updates); |
| 269 EXPECT_EQ(1u, updateable.size()); | 269 EXPECT_EQ(1u, updateable.size()); |
| 270 EXPECT_EQ(0, updateable[0]); | 270 EXPECT_EQ(0, updateable[0]); |
| 271 STLDeleteElements(&updates); | 271 STLDeleteElements(&updates); |
| 272 STLDeleteElements(&tmp); |
| 272 } | 273 } |
| 273 | 274 |
| 274 static void TestMultipleManifestDownloading() { | 275 static void TestMultipleManifestDownloading() { |
| 275 TestURLFetcherFactory factory; | 276 TestURLFetcherFactory factory; |
| 276 TestURLFetcher* fetcher = NULL; | 277 TestURLFetcher* fetcher = NULL; |
| 277 URLFetcher::set_factory(&factory); | 278 URLFetcher::set_factory(&factory); |
| 278 ServiceForDownloadTests service; | 279 ServiceForDownloadTests service; |
| 279 MessageLoop message_loop; | 280 MessageLoop message_loop; |
| 280 scoped_refptr<ExtensionUpdater> updater = | 281 scoped_refptr<ExtensionUpdater> updater = |
| 281 new ExtensionUpdater(&service, kUpdateFrequencySecs, &message_loop); | 282 new ExtensionUpdater(&service, kUpdateFrequencySecs, &message_loop); |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 EXPECT_TRUE(extension_data2 == file_contents); | 408 EXPECT_TRUE(extension_data2 == file_contents); |
| 408 service.FireInstallCallback(); | 409 service.FireInstallCallback(); |
| 409 message_loop.RunAllPending(); | 410 message_loop.RunAllPending(); |
| 410 } | 411 } |
| 411 }; | 412 }; |
| 412 | 413 |
| 413 // Because we test some private methods of ExtensionUpdater, it's easer for the | 414 // Because we test some private methods of ExtensionUpdater, it's easer for the |
| 414 // actual test code to live in ExtenionUpdaterTest methods instead of TEST_F | 415 // actual test code to live in ExtenionUpdaterTest methods instead of TEST_F |
| 415 // subclasses where friendship with ExtenionUpdater is not inherited. | 416 // subclasses where friendship with ExtenionUpdater is not inherited. |
| 416 | 417 |
| 417 TEST(ExtensionUpdaterTest, DISABLED_TestXmlParsing) { | 418 TEST(ExtensionUpdaterTest, TestXmlParsing) { |
| 418 ExtensionUpdaterTest::TestXmlParsing(); | 419 ExtensionUpdaterTest::TestXmlParsing(); |
| 419 } | 420 } |
| 420 | 421 |
| 421 TEST(ExtensionUpdaterTest, DISABLED_TestDetermineUpdates) { | 422 TEST(ExtensionUpdaterTest, TestDetermineUpdates) { |
| 422 ExtensionUpdaterTest::TestDetermineUpdates(); | 423 ExtensionUpdaterTest::TestDetermineUpdates(); |
| 423 } | 424 } |
| 424 | 425 |
| 425 TEST(ExtensionUpdaterTest, DISABLED_TestMultipleManifestDownloading) { | 426 TEST(ExtensionUpdaterTest, TestMultipleManifestDownloading) { |
| 426 ExtensionUpdaterTest::TestMultipleManifestDownloading(); | 427 ExtensionUpdaterTest::TestMultipleManifestDownloading(); |
| 427 } | 428 } |
| 428 | 429 |
| 429 TEST(ExtensionUpdaterTest, DISABLED_TestSingleExtensionDownloading) { | 430 TEST(ExtensionUpdaterTest, TestSingleExtensionDownloading) { |
| 430 ExtensionUpdaterTest::TestSingleExtensionDownloading(); | 431 ExtensionUpdaterTest::TestSingleExtensionDownloading(); |
| 431 } | 432 } |
| 432 | 433 |
| 433 TEST(ExtensionUpdaterTest, DISABLED_TestMultipleExtensionDownloading) { | 434 TEST(ExtensionUpdaterTest, TestMultipleExtensionDownloading) { |
| 434 ExtensionUpdaterTest::TestMultipleExtensionDownloading(); | 435 ExtensionUpdaterTest::TestMultipleExtensionDownloading(); |
| 435 } | 436 } |
| 436 | 437 |
| 437 | 438 |
| 438 // TODO(asargent) - (http://crbug.com/12780) add tests for: | 439 // TODO(asargent) - (http://crbug.com/12780) add tests for: |
| 439 // -prodversionmin (shouldn't update if browser version too old) | 440 // -prodversionmin (shouldn't update if browser version too old) |
| 440 // -manifests & updates arriving out of order / interleaved | 441 // -manifests & updates arriving out of order / interleaved |
| 441 // -Profile::GetDefaultRequestContext() returning null | 442 // -Profile::GetDefaultRequestContext() returning null |
| 442 // (should not crash, but just do check later) | 443 // (should not crash, but just do check later) |
| 443 // -malformed update url (empty, file://, has query, has a # fragment, etc.) | 444 // -malformed update url (empty, file://, has query, has a # fragment, etc.) |
| 444 // -An extension gets uninstalled while updates are in progress (so it doesn't | 445 // -An extension gets uninstalled while updates are in progress (so it doesn't |
| 445 // "come back from the dead") | 446 // "come back from the dead") |
| 446 // -An extension gets manually updated to v3 while we're downloading v2 (ie | 447 // -An extension gets manually updated to v3 while we're downloading v2 (ie |
| 447 // you don't get downgraded accidentally) | 448 // you don't get downgraded accidentally) |
| 448 // -An update manifest mentions multiple updates | 449 // -An update manifest mentions multiple updates |
| OLD | NEW |