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 "chrome/browser/extensions/extension_service_unittest.h" | 5 #include "chrome/browser/extensions/extension_service_unittest.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 3016 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3027 | 3027 |
3028 // Verify that it's not the disabled extensions flag causing it not to load. | 3028 // Verify that it's not the disabled extensions flag causing it not to load. |
3029 set_extensions_enabled(true); | 3029 set_extensions_enabled(true); |
3030 service_->ReloadExtensions(); | 3030 service_->ReloadExtensions(); |
3031 loop_.RunAllPending(); | 3031 loop_.RunAllPending(); |
3032 | 3032 |
3033 ASSERT_EQ(0u, GetErrors().size()); | 3033 ASSERT_EQ(0u, GetErrors().size()); |
3034 ASSERT_EQ(0u, loaded_.size()); | 3034 ASSERT_EQ(0u, loaded_.size()); |
3035 } | 3035 } |
3036 | 3036 |
3037 // Test that running multiple update checks simultaneously does not | |
Erik does not do reviews
2011/01/21 17:05:25
just curious, was there a bug here that this would
Sam Kerner (Chrome)
2011/01/21 17:59:26
No. I created the test while reading the code to
| |
3038 // keep the update from succeeding. | |
3039 TEST_F(ExtensionServiceTest, MultipleExternalUpdateCheck) { | |
3040 InitializeEmptyExtensionService(); | |
3041 | |
3042 MockExtensionProvider* provider = | |
3043 new MockExtensionProvider(service_.get(), Extension::EXTERNAL_PREF); | |
3044 AddMockExternalProvider(provider); | |
3045 | |
3046 // Verify that starting with no providers loads no extensions. | |
3047 service_->Init(); | |
3048 loop_.RunAllPending(); | |
3049 ASSERT_EQ(0u, loaded_.size()); | |
3050 | |
3051 // Start two checks for updates. | |
3052 provider->set_visit_count(0); | |
3053 service_->CheckForExternalUpdates(); | |
3054 service_->CheckForExternalUpdates(); | |
3055 loop_.RunAllPending(); | |
3056 // Two calls should cause two checks for external extensions. | |
Erik does not do reviews
2011/01/21 17:05:25
nit: newline above comment
Sam Kerner (Chrome)
2011/01/21 17:59:26
Done.
| |
3057 EXPECT_EQ(2, provider->visit_count()); | |
3058 EXPECT_EQ(0u, GetErrors().size()); | |
3059 EXPECT_EQ(0u, loaded_.size()); | |
3060 | |
3061 // Register a test extension externally using the mock registry provider. | |
3062 FilePath source_path; | |
3063 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &source_path)); | |
3064 source_path = source_path.AppendASCII("extensions").AppendASCII("good.crx"); | |
3065 provider->UpdateOrAddExtension(good_crx, "1.0.0.0", source_path); | |
3066 | |
3067 // Two checks for external updates should find the extension, an install it | |
Erik does not do reviews
2011/01/21 17:05:25
an->and
Sam Kerner (Chrome)
2011/01/21 17:59:26
Done.
| |
3068 // once. | |
3069 provider->set_visit_count(0); | |
3070 service_->CheckForExternalUpdates(); | |
3071 service_->CheckForExternalUpdates(); | |
3072 loop_.RunAllPending(); | |
3073 EXPECT_EQ(2, provider->visit_count()); | |
3074 ASSERT_EQ(0u, GetErrors().size()); | |
3075 ASSERT_EQ(1u, loaded_.size()); | |
3076 ASSERT_EQ(Extension::EXTERNAL_PREF, loaded_[0]->location()); | |
3077 ASSERT_EQ("1.0.0.0", loaded_[0]->version()->GetString()); | |
3078 ValidatePrefKeyCount(1); | |
3079 ValidateIntegerPref(good_crx, "state", Extension::ENABLED); | |
3080 ValidateIntegerPref(good_crx, "location", Extension::EXTERNAL_PREF); | |
3081 | |
3082 provider->RemoveExtension(good_crx); | |
3083 provider->set_visit_count(0); | |
3084 service_->CheckForExternalUpdates(); | |
3085 service_->CheckForExternalUpdates(); | |
3086 loop_.RunAllPending(); | |
3087 // Two calls should cause two checks for external extensions. | |
Erik does not do reviews
2011/01/21 17:05:25
nit: newline
also, add comment why loaded should b
Sam Kerner (Chrome)
2011/01/21 17:59:26
Done.
| |
3088 EXPECT_EQ(2, provider->visit_count()); | |
3089 EXPECT_EQ(0u, GetErrors().size()); | |
3090 EXPECT_EQ(0u, loaded_.size()); | |
3091 } | |
3092 | |
3037 TEST_F(ExtensionServiceTest, ExternalPrefProvider) { | 3093 TEST_F(ExtensionServiceTest, ExternalPrefProvider) { |
3038 InitializeEmptyExtensionService(); | 3094 InitializeEmptyExtensionService(); |
3039 | 3095 |
3040 // Test some valid extension records. | 3096 // Test some valid extension records. |
3041 // Set a base path to avoid erroring out on relative paths. | 3097 // Set a base path to avoid erroring out on relative paths. |
3042 // Paths starting with // are absolute on every platform we support. | 3098 // Paths starting with // are absolute on every platform we support. |
3043 FilePath base_path(FILE_PATH_LITERAL("//base/path")); | 3099 FilePath base_path(FILE_PATH_LITERAL("//base/path")); |
3044 ASSERT_TRUE(base_path.IsAbsolute()); | 3100 ASSERT_TRUE(base_path.IsAbsolute()); |
3045 MockProviderVisitor visitor(base_path); | 3101 MockProviderVisitor visitor(base_path); |
3046 std::string json_data = | 3102 std::string json_data = |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3352 // Component extensions shouldn't get recourded in the prefs. | 3408 // Component extensions shouldn't get recourded in the prefs. |
3353 ValidatePrefKeyCount(0); | 3409 ValidatePrefKeyCount(0); |
3354 | 3410 |
3355 // Reload all extensions, and make sure it comes back. | 3411 // Reload all extensions, and make sure it comes back. |
3356 std::string extension_id = service_->extensions()->at(0)->id(); | 3412 std::string extension_id = service_->extensions()->at(0)->id(); |
3357 loaded_.clear(); | 3413 loaded_.clear(); |
3358 service_->ReloadExtensions(); | 3414 service_->ReloadExtensions(); |
3359 ASSERT_EQ(1u, service_->extensions()->size()); | 3415 ASSERT_EQ(1u, service_->extensions()->size()); |
3360 EXPECT_EQ(extension_id, service_->extensions()->at(0)->id()); | 3416 EXPECT_EQ(extension_id, service_->extensions()->at(0)->id()); |
3361 } | 3417 } |
OLD | NEW |