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 "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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 #include "chrome/common/chrome_paths.h" | 53 #include "chrome/common/chrome_paths.h" |
54 #include "chrome/common/chrome_switches.h" | 54 #include "chrome/common/chrome_switches.h" |
55 #include "chrome/common/extensions/extension.h" | 55 #include "chrome/common/extensions/extension.h" |
56 #include "chrome/common/extensions/extension_constants.h" | 56 #include "chrome/common/extensions/extension_constants.h" |
57 #include "chrome/common/extensions/extension_resource.h" | 57 #include "chrome/common/extensions/extension_resource.h" |
58 #include "chrome/common/extensions/url_pattern.h" | 58 #include "chrome/common/extensions/url_pattern.h" |
59 #include "chrome/common/pref_names.h" | 59 #include "chrome/common/pref_names.h" |
60 #include "chrome/common/string_ordinal.h" | 60 #include "chrome/common/string_ordinal.h" |
61 #include "chrome/common/url_constants.h" | 61 #include "chrome/common/url_constants.h" |
62 #include "chrome/test/base/testing_profile.h" | 62 #include "chrome/test/base/testing_profile.h" |
63 #include "content/browser/appcache/chrome_appcache_service.h" | |
64 #include "content/browser/in_process_webkit/dom_storage_context.h" | 63 #include "content/browser/in_process_webkit/dom_storage_context.h" |
65 #include "content/browser/in_process_webkit/webkit_context.h" | 64 #include "content/browser/in_process_webkit/webkit_context.h" |
66 #include "content/public/browser/notification_registrar.h" | 65 #include "content/public/browser/notification_registrar.h" |
67 #include "content/public/browser/notification_service.h" | 66 #include "content/public/browser/notification_service.h" |
68 #include "content/public/browser/plugin_service.h" | 67 #include "content/public/browser/plugin_service.h" |
69 #include "content/public/common/content_constants.h" | 68 #include "content/public/common/content_constants.h" |
70 #include "content/test/test_browser_thread.h" | 69 #include "content/test/test_browser_thread.h" |
71 #include "googleurl/src/gurl.h" | 70 #include "googleurl/src/gurl.h" |
72 #include "grit/browser_resources.h" | 71 #include "grit/browser_resources.h" |
73 #include "net/base/cookie_monster.h" | 72 #include "net/base/cookie_monster.h" |
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 return; | 396 return; |
398 } | 397 } |
399 data_dir_ = test_data_dir.AppendASCII("extensions"); | 398 data_dir_ = test_data_dir.AppendASCII("extensions"); |
400 } | 399 } |
401 | 400 |
402 ExtensionServiceTestBase::~ExtensionServiceTestBase() { | 401 ExtensionServiceTestBase::~ExtensionServiceTestBase() { |
403 // Drop our reference to ExtensionService and TestingProfile, so that they | 402 // Drop our reference to ExtensionService and TestingProfile, so that they |
404 // can be destroyed while BrowserThreads and MessageLoop are still around | 403 // can be destroyed while BrowserThreads and MessageLoop are still around |
405 // (they are used in the destruction process). | 404 // (they are used in the destruction process). |
406 service_ = NULL; | 405 service_ = NULL; |
| 406 MessageLoop::current()->RunAllPending(); |
407 profile_.reset(NULL); | 407 profile_.reset(NULL); |
408 MessageLoop::current()->RunAllPending(); | 408 MessageLoop::current()->RunAllPending(); |
409 } | 409 } |
410 | 410 |
411 void ExtensionServiceTestBase::InitializeExtensionService( | 411 void ExtensionServiceTestBase::InitializeExtensionService( |
412 const FilePath& pref_file, const FilePath& extensions_install_dir, | 412 const FilePath& pref_file, const FilePath& extensions_install_dir, |
413 bool autoupdate_enabled) { | 413 bool autoupdate_enabled) { |
414 ExtensionTestingProfile* profile = new ExtensionTestingProfile(); | 414 ExtensionTestingProfile* profile = new ExtensionTestingProfile(); |
415 // Create a PrefService that only contains user defined preference values. | 415 // Create a PrefService that only contains user defined preference values. |
416 PrefService* prefs = | 416 PrefService* prefs = |
(...skipping 3899 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4316 | 4316 |
4317 service_->ProcessSyncChanges(FROM_HERE, list); | 4317 service_->ProcessSyncChanges(FROM_HERE, list); |
4318 EXPECT_FALSE(service_->IsExtensionEnabled(good_crx)); | 4318 EXPECT_FALSE(service_->IsExtensionEnabled(good_crx)); |
4319 EXPECT_TRUE(service_->IsIncognitoEnabled(good_crx)); | 4319 EXPECT_TRUE(service_->IsIncognitoEnabled(good_crx)); |
4320 | 4320 |
4321 EXPECT_FALSE(service_->pending_extension_manager()->IsIdPending(good_crx)); | 4321 EXPECT_FALSE(service_->pending_extension_manager()->IsIdPending(good_crx)); |
4322 } | 4322 } |
4323 | 4323 |
4324 TEST_F(ExtensionServiceTest, ProcessSyncDataVersionCheck) { | 4324 TEST_F(ExtensionServiceTest, ProcessSyncDataVersionCheck) { |
4325 InitializeExtensionServiceWithUpdater(); | 4325 InitializeExtensionServiceWithUpdater(); |
| 4326 InitializeRequestContext(); |
4326 TestSyncProcessorStub processor; | 4327 TestSyncProcessorStub processor; |
4327 service_->MergeDataAndStartSyncing(syncable::EXTENSIONS, SyncDataList(), | 4328 service_->MergeDataAndStartSyncing(syncable::EXTENSIONS, SyncDataList(), |
4328 &processor); | 4329 &processor); |
4329 | 4330 |
4330 InstallCRX(data_dir_.AppendASCII("good.crx"), INSTALL_NEW); | 4331 InstallCRX(data_dir_.AppendASCII("good.crx"), INSTALL_NEW); |
4331 EXPECT_TRUE(service_->IsExtensionEnabled(good_crx)); | 4332 EXPECT_TRUE(service_->IsExtensionEnabled(good_crx)); |
4332 EXPECT_FALSE(service_->IsIncognitoEnabled(good_crx)); | 4333 EXPECT_FALSE(service_->IsIncognitoEnabled(good_crx)); |
4333 | 4334 |
4334 sync_pb::EntitySpecifics specifics; | 4335 sync_pb::EntitySpecifics specifics; |
4335 sync_pb::ExtensionSpecifics* ext_specifics = | 4336 sync_pb::ExtensionSpecifics* ext_specifics = |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4373 | 4374 |
4374 service_->ProcessSyncChanges(FROM_HERE, list); | 4375 service_->ProcessSyncChanges(FROM_HERE, list); |
4375 EXPECT_TRUE(service_->updater()->WillCheckSoon()); | 4376 EXPECT_TRUE(service_->updater()->WillCheckSoon()); |
4376 } | 4377 } |
4377 | 4378 |
4378 EXPECT_FALSE(service_->pending_extension_manager()->IsIdPending(good_crx)); | 4379 EXPECT_FALSE(service_->pending_extension_manager()->IsIdPending(good_crx)); |
4379 } | 4380 } |
4380 | 4381 |
4381 TEST_F(ExtensionServiceTest, ProcessSyncDataNotInstalled) { | 4382 TEST_F(ExtensionServiceTest, ProcessSyncDataNotInstalled) { |
4382 InitializeExtensionServiceWithUpdater(); | 4383 InitializeExtensionServiceWithUpdater(); |
| 4384 InitializeRequestContext(); |
4383 TestSyncProcessorStub processor; | 4385 TestSyncProcessorStub processor; |
4384 service_->MergeDataAndStartSyncing(syncable::EXTENSIONS, SyncDataList(), | 4386 service_->MergeDataAndStartSyncing(syncable::EXTENSIONS, SyncDataList(), |
4385 &processor); | 4387 &processor); |
4386 | 4388 |
4387 sync_pb::EntitySpecifics specifics; | 4389 sync_pb::EntitySpecifics specifics; |
4388 sync_pb::ExtensionSpecifics* ext_specifics = | 4390 sync_pb::ExtensionSpecifics* ext_specifics = |
4389 specifics.MutableExtension(sync_pb::extension); | 4391 specifics.MutableExtension(sync_pb::extension); |
4390 ext_specifics->set_id(good_crx); | 4392 ext_specifics->set_id(good_crx); |
4391 ext_specifics->set_enabled(false); | 4393 ext_specifics->set_enabled(false); |
4392 ext_specifics->set_incognito_enabled(true); | 4394 ext_specifics->set_incognito_enabled(true); |
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4782 ASSERT_FALSE(AddPendingSyncInstall()); | 4784 ASSERT_FALSE(AddPendingSyncInstall()); |
4783 | 4785 |
4784 // Wait for the external source to install. | 4786 // Wait for the external source to install. |
4785 WaitForCrxInstall(crx_path_, INSTALL_NEW); | 4787 WaitForCrxInstall(crx_path_, INSTALL_NEW); |
4786 ASSERT_TRUE(IsCrxInstalled()); | 4788 ASSERT_TRUE(IsCrxInstalled()); |
4787 | 4789 |
4788 // Now that the extension is installed, sync request should fail | 4790 // Now that the extension is installed, sync request should fail |
4789 // because the extension is already installed. | 4791 // because the extension is already installed. |
4790 ASSERT_FALSE(AddPendingSyncInstall()); | 4792 ASSERT_FALSE(AddPendingSyncInstall()); |
4791 } | 4793 } |
OLD | NEW |