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/themes/theme_syncable_service.h" | 5 #include "chrome/browser/themes/theme_syncable_service.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
12 #include "chrome/browser/extensions/extension_service.h" | 12 #include "chrome/browser/extensions/extension_service.h" |
13 #include "chrome/browser/extensions/test_extension_system.h" | 13 #include "chrome/browser/extensions/test_extension_system.h" |
14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
15 #include "chrome/browser/themes/theme_service.h" | 15 #include "chrome/browser/themes/theme_service.h" |
16 #include "chrome/browser/themes/theme_service_factory.h" | 16 #include "chrome/browser/themes/theme_service_factory.h" |
17 #include "chrome/common/extensions/manifest_url_handler.h" | 17 #include "chrome/common/extensions/manifest_url_handler.h" |
18 #include "chrome/test/base/testing_profile.h" | 18 #include "chrome/test/base/testing_profile.h" |
19 #include "content/public/test/test_browser_thread.h" | 19 #include "content/public/test/test_browser_thread.h" |
20 #include "extensions/common/extension.h" | 20 #include "extensions/common/extension.h" |
21 #include "extensions/common/extension_messages.h" | 21 #include "extensions/common/extension_messages.h" |
22 #include "extensions/common/manifest_constants.h" | 22 #include "extensions/common/manifest_constants.h" |
23 #include "extensions/common/permissions/api_permission_set.h" | 23 #include "extensions/common/permissions/api_permission_set.h" |
24 #include "extensions/common/permissions/permission_set.h" | 24 #include "extensions/common/permissions/permission_set.h" |
| 25 #include "sync/api/attachments/attachment_id.h" |
| 26 #include "sync/api/attachments/attachment_service_proxy_for_test.h" |
25 #include "sync/api/fake_sync_change_processor.h" | 27 #include "sync/api/fake_sync_change_processor.h" |
26 #include "sync/api/sync_change_processor_wrapper_for_test.h" | 28 #include "sync/api/sync_change_processor_wrapper_for_test.h" |
27 #include "sync/api/sync_error.h" | 29 #include "sync/api/sync_error.h" |
28 #include "sync/api/sync_error_factory_mock.h" | 30 #include "sync/api/sync_error_factory_mock.h" |
29 #include "sync/protocol/sync.pb.h" | 31 #include "sync/protocol/sync.pb.h" |
30 #include "sync/protocol/theme_specifics.pb.h" | 32 #include "sync/protocol/theme_specifics.pb.h" |
31 #include "testing/gtest/include/gtest/gtest.h" | 33 #include "testing/gtest/include/gtest/gtest.h" |
32 | 34 |
33 #if defined(OS_CHROMEOS) | 35 #if defined(OS_CHROMEOS) |
34 #include "chrome/browser/chromeos/login/user_manager.h" | 36 #include "chrome/browser/chromeos/login/user_manager.h" |
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 | 446 |
445 // Change specifics to use custom theme and update. | 447 // Change specifics to use custom theme and update. |
446 sync_pb::ThemeSpecifics theme_specifics; | 448 sync_pb::ThemeSpecifics theme_specifics; |
447 theme_specifics.set_use_custom_theme(true); | 449 theme_specifics.set_use_custom_theme(true); |
448 theme_specifics.set_custom_theme_id(theme_extension_->id()); | 450 theme_specifics.set_custom_theme_id(theme_extension_->id()); |
449 theme_specifics.set_custom_theme_name(kCustomThemeName); | 451 theme_specifics.set_custom_theme_name(kCustomThemeName); |
450 theme_specifics.set_custom_theme_name(kCustomThemeUrl); | 452 theme_specifics.set_custom_theme_name(kCustomThemeUrl); |
451 sync_pb::EntitySpecifics entity_specifics; | 453 sync_pb::EntitySpecifics entity_specifics; |
452 entity_specifics.mutable_theme()->CopyFrom(theme_specifics); | 454 entity_specifics.mutable_theme()->CopyFrom(theme_specifics); |
453 syncer::SyncChangeList change_list; | 455 syncer::SyncChangeList change_list; |
454 change_list.push_back(syncer::SyncChange( | 456 change_list.push_back( |
455 FROM_HERE, | 457 syncer::SyncChange(FROM_HERE, |
456 syncer::SyncChange::ACTION_UPDATE, | 458 syncer::SyncChange::ACTION_UPDATE, |
457 syncer::SyncData::CreateRemoteData( | 459 syncer::SyncData::CreateRemoteData( |
458 1, entity_specifics, base::Time()))); | 460 1, |
| 461 entity_specifics, |
| 462 base::Time(), |
| 463 syncer::AttachmentIdList(), |
| 464 syncer::AttachmentServiceProxyForTest::Create()))); |
459 error = theme_sync_service_->ProcessSyncChanges(FROM_HERE, change_list); | 465 error = theme_sync_service_->ProcessSyncChanges(FROM_HERE, change_list); |
460 EXPECT_FALSE(error.IsSet()) << error.message(); | 466 EXPECT_FALSE(error.IsSet()) << error.message(); |
461 EXPECT_EQ(fake_theme_service_->theme_extension(), theme_extension_.get()); | 467 EXPECT_EQ(fake_theme_service_->theme_extension(), theme_extension_.get()); |
462 } | 468 } |
463 | 469 |
464 TEST_F(ThemeSyncableServiceTest, OnThemeChangeByUser) { | 470 TEST_F(ThemeSyncableServiceTest, OnThemeChangeByUser) { |
465 // Set up theme service to use default theme. | 471 // Set up theme service to use default theme. |
466 fake_theme_service_->UseDefaultTheme(); | 472 fake_theme_service_->UseDefaultTheme(); |
467 | 473 |
468 // Start syncing. | 474 // Start syncing. |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
649 | 655 |
650 TEST_F(PolicyInstalledThemeTest, InstallThemeByPolicy) { | 656 TEST_F(PolicyInstalledThemeTest, InstallThemeByPolicy) { |
651 // Set up theme service to use custom theme that was installed by policy. | 657 // Set up theme service to use custom theme that was installed by policy. |
652 fake_theme_service_->SetTheme(theme_extension_.get()); | 658 fake_theme_service_->SetTheme(theme_extension_.get()); |
653 | 659 |
654 syncer::SyncDataList data_list = | 660 syncer::SyncDataList data_list = |
655 theme_sync_service_->GetAllSyncData(syncer::THEMES); | 661 theme_sync_service_->GetAllSyncData(syncer::THEMES); |
656 | 662 |
657 ASSERT_EQ(0u, data_list.size()); | 663 ASSERT_EQ(0u, data_list.size()); |
658 } | 664 } |
OLD | NEW |