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

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

Issue 7795011: Fixing crash on sync when app becomes extension or vice versa. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 3 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
« no previous file with comments | « chrome/browser/extensions/extension_service.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 22 matching lines...) Expand all
33 #include "chrome/browser/extensions/extension_updater.h" 33 #include "chrome/browser/extensions/extension_updater.h"
34 #include "chrome/browser/extensions/external_extension_provider_impl.h" 34 #include "chrome/browser/extensions/external_extension_provider_impl.h"
35 #include "chrome/browser/extensions/external_extension_provider_interface.h" 35 #include "chrome/browser/extensions/external_extension_provider_interface.h"
36 #include "chrome/browser/extensions/external_pref_extension_loader.h" 36 #include "chrome/browser/extensions/external_pref_extension_loader.h"
37 #include "chrome/browser/extensions/pack_extension_job.cc" 37 #include "chrome/browser/extensions/pack_extension_job.cc"
38 #include "chrome/browser/extensions/pending_extension_info.h" 38 #include "chrome/browser/extensions/pending_extension_info.h"
39 #include "chrome/browser/extensions/pending_extension_manager.h" 39 #include "chrome/browser/extensions/pending_extension_manager.h"
40 #include "chrome/browser/prefs/browser_prefs.h" 40 #include "chrome/browser/prefs/browser_prefs.h"
41 #include "chrome/browser/prefs/pref_service_mock_builder.h" 41 #include "chrome/browser/prefs/pref_service_mock_builder.h"
42 #include "chrome/browser/prefs/scoped_user_pref_update.h" 42 #include "chrome/browser/prefs/scoped_user_pref_update.h"
43 #include "chrome/browser/sync/protocol/app_specifics.pb.h"
43 #include "chrome/browser/sync/protocol/extension_specifics.pb.h" 44 #include "chrome/browser/sync/protocol/extension_specifics.pb.h"
44 #include "chrome/common/chrome_notification_types.h" 45 #include "chrome/common/chrome_notification_types.h"
45 #include "chrome/common/chrome_paths.h" 46 #include "chrome/common/chrome_paths.h"
46 #include "chrome/common/chrome_switches.h" 47 #include "chrome/common/chrome_switches.h"
47 #include "chrome/common/extensions/extension.h" 48 #include "chrome/common/extensions/extension.h"
48 #include "chrome/common/extensions/extension_constants.h" 49 #include "chrome/common/extensions/extension_constants.h"
49 #include "chrome/common/extensions/extension_resource.h" 50 #include "chrome/common/extensions/extension_resource.h"
50 #include "chrome/common/extensions/url_pattern.h" 51 #include "chrome/common/extensions/url_pattern.h"
51 #include "chrome/common/pref_names.h" 52 #include "chrome/common/pref_names.h"
52 #include "chrome/common/url_constants.h" 53 #include "chrome/common/url_constants.h"
(...skipping 3552 matching lines...) Expand 10 before | Expand all | Expand 10 after
3605 3606
3606 // Should uninstall the extension. 3607 // Should uninstall the extension.
3607 service_->ProcessSyncChanges(FROM_HERE, list); 3608 service_->ProcessSyncChanges(FROM_HERE, list);
3608 EXPECT_FALSE(service_->GetExtensionById(good_crx, true)); 3609 EXPECT_FALSE(service_->GetExtensionById(good_crx, true));
3609 3610
3610 // Should again do nothing. 3611 // Should again do nothing.
3611 service_->ProcessSyncChanges(FROM_HERE, list); 3612 service_->ProcessSyncChanges(FROM_HERE, list);
3612 EXPECT_FALSE(service_->GetExtensionById(good_crx, true)); 3613 EXPECT_FALSE(service_->GetExtensionById(good_crx, true));
3613 } 3614 }
3614 3615
3616 TEST_F(ExtensionServiceTest, ProcessSyncDataWrongType) {
3617 InitializeEmptyExtensionService();
3618
3619 // Install the extension.
3620 FilePath extension_path = data_dir_.AppendASCII("good.crx");
3621 InstallCrx(extension_path, true);
3622 EXPECT_TRUE(service_->GetExtensionById(good_crx, true));
3623
3624 sync_pb::EntitySpecifics specifics;
3625 sync_pb::AppSpecifics* app_specifics =
3626 specifics.MutableExtension(sync_pb::app);
3627 sync_pb::ExtensionSpecifics* extension_specifics =
3628 app_specifics->mutable_extension();
3629 extension_specifics->set_id(good_crx);
3630 extension_specifics->set_version(
3631 service_->GetInstalledExtension(good_crx)->version()->GetString());
3632
3633 {
3634 extension_specifics->set_enabled(true);
3635 SyncData sync_data = SyncData::CreateLocalData(good_crx, "Name", specifics);
3636 SyncChange sync_change(SyncChange::ACTION_DELETE, sync_data);
3637 SyncChangeList list(1);
3638 list[0] = sync_change;
3639
3640 // Should do nothing
3641 service_->ProcessSyncChanges(FROM_HERE, list);
3642 EXPECT_TRUE(service_->GetExtensionById(good_crx, true));
3643 }
3644
3645 {
3646 extension_specifics->set_enabled(false);
3647 SyncData sync_data = SyncData::CreateLocalData(good_crx, "Name", specifics);
3648 SyncChange sync_change(SyncChange::ACTION_UPDATE, sync_data);
3649 SyncChangeList list(1);
3650 list[0] = sync_change;
3651
3652 // Should again do nothing.
3653 service_->ProcessSyncChanges(FROM_HERE, list);
3654 EXPECT_TRUE(service_->GetExtensionById(good_crx, false));
3655 }
3656 }
3657
3615 TEST_F(ExtensionServiceTest, ProcessSyncDataSettings) { 3658 TEST_F(ExtensionServiceTest, ProcessSyncDataSettings) {
3616 InitializeEmptyExtensionService(); 3659 InitializeEmptyExtensionService();
3617 TestSyncProcessorStub processor; 3660 TestSyncProcessorStub processor;
3618 service_->MergeDataAndStartSyncing(syncable::EXTENSIONS, SyncDataList(), 3661 service_->MergeDataAndStartSyncing(syncable::EXTENSIONS, SyncDataList(),
3619 &processor); 3662 &processor);
3620 3663
3621 InstallCrx(data_dir_.AppendASCII("good.crx"), true); 3664 InstallCrx(data_dir_.AppendASCII("good.crx"), true);
3622 EXPECT_TRUE(service_->IsExtensionEnabled(good_crx)); 3665 EXPECT_TRUE(service_->IsExtensionEnabled(good_crx));
3623 EXPECT_FALSE(service_->IsIncognitoEnabled(good_crx)); 3666 EXPECT_FALSE(service_->IsIncognitoEnabled(good_crx));
3624 3667
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
3963 ASSERT_FALSE(AddPendingSyncInstall()); 4006 ASSERT_FALSE(AddPendingSyncInstall());
3964 4007
3965 // Wait for the external source to install. 4008 // Wait for the external source to install.
3966 WaitForCrxInstall(crx_path_, true); 4009 WaitForCrxInstall(crx_path_, true);
3967 ASSERT_TRUE(IsCrxInstalled()); 4010 ASSERT_TRUE(IsCrxInstalled());
3968 4011
3969 // Now that the extension is installed, sync request should fail 4012 // Now that the extension is installed, sync request should fail
3970 // because the extension is already installed. 4013 // because the extension is already installed.
3971 ASSERT_FALSE(AddPendingSyncInstall()); 4014 ASSERT_FALSE(AddPendingSyncInstall());
3972 } 4015 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_service.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698