Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(842)

Side by Side Diff: chrome/browser/extensions/extension_service_unittest.cc

Issue 6370009: Add in-profile external_extensions.json file for Chrome OS OEM customization. (Closed) Base URL: http://git.chromium.org/git/chromium.git
Patch Set: Address review comments. Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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
3057 // Two calls should cause two checks for external extensions.
3058 EXPECT_EQ(2, provider->visit_count());
3059 EXPECT_EQ(0u, GetErrors().size());
3060 EXPECT_EQ(0u, loaded_.size());
3061
3062 // Register a test extension externally using the mock registry provider.
3063 FilePath source_path;
3064 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &source_path));
3065 source_path = source_path.AppendASCII("extensions").AppendASCII("good.crx");
3066 provider->UpdateOrAddExtension(good_crx, "1.0.0.0", source_path);
3067
3068 // Two checks for external updates should find the extension, and install it
3069 // once.
3070 provider->set_visit_count(0);
3071 service_->CheckForExternalUpdates();
3072 service_->CheckForExternalUpdates();
3073 loop_.RunAllPending();
3074 EXPECT_EQ(2, provider->visit_count());
3075 ASSERT_EQ(0u, GetErrors().size());
3076 ASSERT_EQ(1u, loaded_.size());
3077 ASSERT_EQ(Extension::EXTERNAL_PREF, loaded_[0]->location());
3078 ASSERT_EQ("1.0.0.0", loaded_[0]->version()->GetString());
3079 ValidatePrefKeyCount(1);
3080 ValidateIntegerPref(good_crx, "state", Extension::ENABLED);
3081 ValidateIntegerPref(good_crx, "location", Extension::EXTERNAL_PREF);
3082
3083 provider->RemoveExtension(good_crx);
3084 provider->set_visit_count(0);
3085 service_->CheckForExternalUpdates();
3086 service_->CheckForExternalUpdates();
3087 loop_.RunAllPending();
3088
3089 // Two calls should cause two checks for external extensions.
3090 // Because the external source no longer includes good_crx,
3091 // good_crx will be uninstalled. So, expect that no extensions
3092 // are loaded.
3093 EXPECT_EQ(2, provider->visit_count());
3094 EXPECT_EQ(0u, GetErrors().size());
3095 EXPECT_EQ(0u, loaded_.size());
3096 }
3097
3037 TEST_F(ExtensionServiceTest, ExternalPrefProvider) { 3098 TEST_F(ExtensionServiceTest, ExternalPrefProvider) {
3038 InitializeEmptyExtensionService(); 3099 InitializeEmptyExtensionService();
3039 3100
3040 // Test some valid extension records. 3101 // Test some valid extension records.
3041 // Set a base path to avoid erroring out on relative paths. 3102 // Set a base path to avoid erroring out on relative paths.
3042 // Paths starting with // are absolute on every platform we support. 3103 // Paths starting with // are absolute on every platform we support.
3043 FilePath base_path(FILE_PATH_LITERAL("//base/path")); 3104 FilePath base_path(FILE_PATH_LITERAL("//base/path"));
3044 ASSERT_TRUE(base_path.IsAbsolute()); 3105 ASSERT_TRUE(base_path.IsAbsolute());
3045 MockProviderVisitor visitor(base_path); 3106 MockProviderVisitor visitor(base_path);
3046 std::string json_data = 3107 std::string json_data =
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
3352 // Component extensions shouldn't get recourded in the prefs. 3413 // Component extensions shouldn't get recourded in the prefs.
3353 ValidatePrefKeyCount(0); 3414 ValidatePrefKeyCount(0);
3354 3415
3355 // Reload all extensions, and make sure it comes back. 3416 // Reload all extensions, and make sure it comes back.
3356 std::string extension_id = service_->extensions()->at(0)->id(); 3417 std::string extension_id = service_->extensions()->at(0)->id();
3357 loaded_.clear(); 3418 loaded_.clear();
3358 service_->ReloadExtensions(); 3419 service_->ReloadExtensions();
3359 ASSERT_EQ(1u, service_->extensions()->size()); 3420 ASSERT_EQ(1u, service_->extensions()->size());
3360 EXPECT_EQ(extension_id, service_->extensions()->at(0)->id()); 3421 EXPECT_EQ(extension_id, service_->extensions()->at(0)->id());
3361 } 3422 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_service.cc ('k') | chrome/browser/extensions/external_extension_provider_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698