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 <stddef.h> | 5 #include <stddef.h> |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
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/files/file_path.h" | 11 #include "base/files/file_path.h" |
12 #include "base/files/file_util.h" | 12 #include "base/files/file_util.h" |
13 #include "base/files/scoped_temp_dir.h" | 13 #include "base/files/scoped_temp_dir.h" |
14 #include "base/json/json_file_value_serializer.h" | 14 #include "base/json/json_file_value_serializer.h" |
15 #include "base/json/json_reader.h" | 15 #include "base/json/json_reader.h" |
16 #include "base/json/json_writer.h" | 16 #include "base/json/json_writer.h" |
17 #include "base/message_loop/message_loop.h" | |
18 #include "base/path_service.h" | 17 #include "base/path_service.h" |
19 #include "base/run_loop.h" | 18 #include "base/run_loop.h" |
20 #include "base/sequenced_task_runner.h" | 19 #include "base/sequenced_task_runner.h" |
21 #include "base/strings/string_util.h" | 20 #include "base/strings/string_util.h" |
22 #include "base/strings/utf_string_conversions.h" | 21 #include "base/strings/utf_string_conversions.h" |
23 #include "base/test/scoped_path_override.h" | 22 #include "base/test/scoped_path_override.h" |
24 #include "base/threading/thread_task_runner_handle.h" | 23 #include "base/threading/thread_task_runner_handle.h" |
25 #include "base/values.h" | 24 #include "base/values.h" |
26 #include "chrome/browser/component_updater/supervised_user_whitelist_installer.h
" | 25 #include "chrome/browser/component_updater/supervised_user_whitelist_installer.h
" |
27 #include "chrome/browser/profiles/profile_attributes_storage.h" | 26 #include "chrome/browser/profiles/profile_attributes_storage.h" |
28 #include "chrome/common/chrome_paths.h" | 27 #include "chrome/common/chrome_paths.h" |
29 #include "chrome/common/pref_names.h" | 28 #include "chrome/common/pref_names.h" |
30 #include "chrome/test/base/testing_browser_process.h" | 29 #include "chrome/test/base/testing_browser_process.h" |
31 #include "chrome/test/base/testing_profile_manager.h" | 30 #include "chrome/test/base/testing_profile_manager.h" |
32 #include "components/component_updater/component_updater_paths.h" | 31 #include "components/component_updater/component_updater_paths.h" |
33 #include "components/component_updater/component_updater_service.h" | 32 #include "components/component_updater/component_updater_service.h" |
34 #include "components/crx_file/id_util.h" | 33 #include "components/crx_file/id_util.h" |
35 #include "components/prefs/testing_pref_service.h" | 34 #include "components/prefs/testing_pref_service.h" |
36 #include "components/safe_json/testing_json_parser.h" | 35 #include "components/safe_json/testing_json_parser.h" |
37 #include "components/update_client/crx_update_item.h" | 36 #include "components/update_client/crx_update_item.h" |
38 #include "components/update_client/update_client.h" | 37 #include "components/update_client/update_client.h" |
39 #include "components/update_client/utils.h" | 38 #include "components/update_client/utils.h" |
| 39 #include "content/public/test/test_browser_thread_bundle.h" |
40 #include "testing/gmock/include/gmock/gmock.h" | 40 #include "testing/gmock/include/gmock/gmock.h" |
41 #include "testing/gtest/include/gtest/gtest.h" | 41 #include "testing/gtest/include/gtest/gtest.h" |
42 | 42 |
43 using update_client::CrxComponent; | 43 using update_client::CrxComponent; |
44 using update_client::CrxUpdateItem; | 44 using update_client::CrxUpdateItem; |
45 | 45 |
46 namespace component_updater { | 46 namespace component_updater { |
47 | 47 |
48 namespace { | 48 namespace { |
49 | 49 |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 | 288 |
289 void CheckRegisteredComponent(const char* version) { | 289 void CheckRegisteredComponent(const char* version) { |
290 const CrxComponent* component = | 290 const CrxComponent* component = |
291 component_update_service_.registered_component(); | 291 component_update_service_.registered_component(); |
292 ASSERT_TRUE(component); | 292 ASSERT_TRUE(component); |
293 EXPECT_EQ(kName, component->name); | 293 EXPECT_EQ(kName, component->name); |
294 EXPECT_EQ(kCrxId, GetCrxComponentID(*component)); | 294 EXPECT_EQ(kCrxId, GetCrxComponentID(*component)); |
295 EXPECT_EQ(version, component->version.GetString()); | 295 EXPECT_EQ(version, component->version.GetString()); |
296 } | 296 } |
297 | 297 |
298 base::MessageLoop message_loop_; | 298 content::TestBrowserThreadBundle thread_bundle_; |
299 TestingProfileManager testing_profile_manager_; | 299 TestingProfileManager testing_profile_manager_; |
300 base::ScopedPathOverride user_data_dir_override_; | 300 base::ScopedPathOverride user_data_dir_override_; |
301 safe_json::TestingJsonParser::ScopedFactoryOverride json_parser_override_; | 301 safe_json::TestingJsonParser::ScopedFactoryOverride json_parser_override_; |
302 MockComponentUpdateService component_update_service_; | 302 MockComponentUpdateService component_update_service_; |
303 TestingPrefServiceSimple local_state_; | 303 TestingPrefServiceSimple local_state_; |
304 std::unique_ptr<SupervisedUserWhitelistInstaller> installer_; | 304 std::unique_ptr<SupervisedUserWhitelistInstaller> installer_; |
305 base::FilePath whitelist_base_directory_; | 305 base::FilePath whitelist_base_directory_; |
306 base::FilePath whitelist_directory_; | 306 base::FilePath whitelist_directory_; |
307 base::FilePath whitelist_version_directory_; | 307 base::FilePath whitelist_version_directory_; |
308 base::FilePath installed_whitelist_directory_; | 308 base::FilePath installed_whitelist_directory_; |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 // but it exercises a different code path. | 427 // but it exercises a different code path. |
428 profile_attributes_storage()->RemoveProfile(GetProfilePath(kOtherClientId)); | 428 profile_attributes_storage()->RemoveProfile(GetProfilePath(kOtherClientId)); |
429 run_loop.RunUntilIdle(); | 429 run_loop.RunUntilIdle(); |
430 } | 430 } |
431 EXPECT_FALSE(component_update_service_.registered_component()); | 431 EXPECT_FALSE(component_update_service_.registered_component()); |
432 EXPECT_FALSE(base::DirectoryExists(whitelist_directory_)); | 432 EXPECT_FALSE(base::DirectoryExists(whitelist_directory_)); |
433 EXPECT_FALSE(base::PathExists(whitelist_path_)); | 433 EXPECT_FALSE(base::PathExists(whitelist_path_)); |
434 } | 434 } |
435 | 435 |
436 } // namespace component_updater | 436 } // namespace component_updater |
OLD | NEW |