| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <map> | 5 #include <map> |
| 6 #include <set> | 6 #include <set> |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
| 13 #include "base/path_service.h" | 13 #include "base/path_service.h" |
| 14 #include "base/prefs/scoped_user_pref_update.h" | 14 #include "base/prefs/scoped_user_pref_update.h" |
| 15 #include "base/run_loop.h" | 15 #include "base/run_loop.h" |
| 16 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
| 17 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
| 18 #include "chrome/browser/component_updater/supervised_user_whitelist_installer.h
" | 18 #include "chrome/browser/component_updater/supervised_user_whitelist_installer.h
" |
| 19 #include "chrome/browser/supervised_user/supervised_user_site_list.h" | 19 #include "chrome/browser/supervised_user/supervised_user_site_list.h" |
| 20 #include "chrome/browser/supervised_user/supervised_user_whitelist_service.h" | 20 #include "chrome/browser/supervised_user/supervised_user_whitelist_service.h" |
| 21 #include "chrome/common/chrome_paths.h" | 21 #include "chrome/common/chrome_paths.h" |
| 22 #include "chrome/common/pref_names.h" | 22 #include "chrome/common/pref_names.h" |
| 23 #include "chrome/test/base/testing_profile.h" | 23 #include "chrome/test/base/testing_profile.h" |
| 24 #include "components/safe_json/testing_json_parser.h" | |
| 25 #include "content/public/test/test_browser_thread_bundle.h" | 24 #include "content/public/test/test_browser_thread_bundle.h" |
| 26 #include "sync/api/sync_change.h" | 25 #include "sync/api/sync_change.h" |
| 27 #include "sync/api/sync_error_factory.h" | 26 #include "sync/api/sync_error_factory.h" |
| 28 #include "sync/protocol/sync.pb.h" | 27 #include "sync/protocol/sync.pb.h" |
| 29 #include "testing/gtest/include/gtest/gtest.h" | 28 #include "testing/gtest/include/gtest/gtest.h" |
| 30 | 29 |
| 30 #if !defined(OS_ANDROID) |
| 31 #include "components/safe_json/testing_json_parser.h" |
| 32 #endif |
| 33 |
| 31 namespace { | 34 namespace { |
| 32 | 35 |
| 33 const char kClientId[] = "client-id"; | 36 const char kClientId[] = "client-id"; |
| 34 | 37 |
| 35 class MockSupervisedUserWhitelistInstaller | 38 class MockSupervisedUserWhitelistInstaller |
| 36 : public component_updater::SupervisedUserWhitelistInstaller { | 39 : public component_updater::SupervisedUserWhitelistInstaller { |
| 37 public: | 40 public: |
| 38 MockSupervisedUserWhitelistInstaller() {} | 41 MockSupervisedUserWhitelistInstaller() {} |
| 39 ~MockSupervisedUserWhitelistInstaller() override {} | 42 ~MockSupervisedUserWhitelistInstaller() override {} |
| 40 | 43 |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 void OnSiteListsChanged( | 148 void OnSiteListsChanged( |
| 146 const std::vector<scoped_refptr<SupervisedUserSiteList>>& site_lists) { | 149 const std::vector<scoped_refptr<SupervisedUserSiteList>>& site_lists) { |
| 147 site_lists_ = site_lists; | 150 site_lists_ = site_lists; |
| 148 if (!site_lists_changed_callback_.is_null()) | 151 if (!site_lists_changed_callback_.is_null()) |
| 149 site_lists_changed_callback_.Run(); | 152 site_lists_changed_callback_.Run(); |
| 150 } | 153 } |
| 151 | 154 |
| 152 content::TestBrowserThreadBundle thread_bundle_; | 155 content::TestBrowserThreadBundle thread_bundle_; |
| 153 TestingProfile profile_; | 156 TestingProfile profile_; |
| 154 | 157 |
| 158 #if !defined(OS_ANDROID) |
| 155 safe_json::TestingJsonParser::ScopedFactoryOverride factory_override_; | 159 safe_json::TestingJsonParser::ScopedFactoryOverride factory_override_; |
| 160 #endif |
| 156 | 161 |
| 157 scoped_ptr<MockSupervisedUserWhitelistInstaller> installer_; | 162 scoped_ptr<MockSupervisedUserWhitelistInstaller> installer_; |
| 158 scoped_ptr<SupervisedUserWhitelistService> service_; | 163 scoped_ptr<SupervisedUserWhitelistService> service_; |
| 159 | 164 |
| 160 std::vector<scoped_refptr<SupervisedUserSiteList>> site_lists_; | 165 std::vector<scoped_refptr<SupervisedUserSiteList>> site_lists_; |
| 161 base::Closure site_lists_changed_callback_; | 166 base::Closure site_lists_changed_callback_; |
| 162 }; | 167 }; |
| 163 | 168 |
| 164 TEST_F(SupervisedUserWhitelistServiceTest, MergeEmpty) { | 169 TEST_F(SupervisedUserWhitelistServiceTest, MergeEmpty) { |
| 165 service_->Init(); | 170 service_->Init(); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 service_->GetAllSyncData(syncer::SUPERVISED_USER_WHITELISTS); | 272 service_->GetAllSyncData(syncer::SUPERVISED_USER_WHITELISTS); |
| 268 ASSERT_EQ(2u, sync_data.size()); | 273 ASSERT_EQ(2u, sync_data.size()); |
| 269 const sync_pb::ManagedUserWhitelistSpecifics* whitelist = | 274 const sync_pb::ManagedUserWhitelistSpecifics* whitelist = |
| 270 FindWhitelist(sync_data, "aaaa"); | 275 FindWhitelist(sync_data, "aaaa"); |
| 271 ASSERT_TRUE(whitelist); | 276 ASSERT_TRUE(whitelist); |
| 272 EXPECT_EQ("Whitelist A", whitelist->name()); | 277 EXPECT_EQ("Whitelist A", whitelist->name()); |
| 273 whitelist = FindWhitelist(sync_data, "bbbb"); | 278 whitelist = FindWhitelist(sync_data, "bbbb"); |
| 274 ASSERT_TRUE(whitelist); | 279 ASSERT_TRUE(whitelist); |
| 275 EXPECT_EQ("Whitelist B", whitelist->name()); | 280 EXPECT_EQ("Whitelist B", whitelist->name()); |
| 276 } | 281 } |
| OLD | NEW |