| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 <vector> | 5 #include <vector> |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| 11 #include "build/build_config.h" | 11 #include "build/build_config.h" |
| 12 #include "chrome/browser/chromeos/extensions/users_private/users_private_delegat
e.h" | 12 #include "chrome/browser/chromeos/extensions/users_private/users_private_delegat
e.h" |
| 13 #include "chrome/browser/chromeos/extensions/users_private/users_private_delegat
e_factory.h" | 13 #include "chrome/browser/chromeos/extensions/users_private/users_private_delegat
e_factory.h" |
| 14 #include "chrome/browser/extensions/api/settings_private/prefs_util.h" | 14 #include "chrome/browser/extensions/api/settings_private/prefs_util.h" |
| 15 #include "chrome/browser/extensions/extension_apitest.h" | 15 #include "chrome/browser/extensions/extension_apitest.h" |
| 16 #include "chrome/common/extensions/api/users_private.h" | 16 #include "chrome/common/extensions/api/users_private.h" |
| 17 #include "components/keyed_service/core/keyed_service.h" | 17 #include "components/keyed_service/core/keyed_service.h" |
| 18 #include "components/prefs/pref_service.h" | 18 #include "components/prefs/pref_service.h" |
| 19 #include "content/public/test/test_utils.h" | 19 #include "content/public/test/test_utils.h" |
| 20 #include "extensions/common/switches.h" | 20 #include "extensions/common/switches.h" |
| 21 | 21 |
| 22 #if defined(OS_CHROMEOS) | 22 #if defined(OS_CHROMEOS) |
| 23 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos_fact
ory.h" |
| 23 #include "chromeos/chromeos_switches.h" | 24 #include "chromeos/chromeos_switches.h" |
| 25 #include "components/ownership/mock_owner_key_util.h" |
| 26 #include "crypto/rsa_private_key.h" |
| 24 #endif | 27 #endif |
| 25 | 28 |
| 26 namespace extensions { | 29 namespace extensions { |
| 27 | 30 |
| 28 namespace { | 31 namespace { |
| 29 | 32 |
| 30 class TestPrefsUtil : public PrefsUtil { | 33 class TestPrefsUtil : public PrefsUtil { |
| 31 public: | 34 public: |
| 32 explicit TestPrefsUtil(Profile* profile) : PrefsUtil(profile) {} | 35 explicit TestPrefsUtil(Profile* profile) : PrefsUtil(profile) {} |
| 33 | 36 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 | 102 |
| 100 private: | 103 private: |
| 101 Profile* profile_; // weak | 104 Profile* profile_; // weak |
| 102 std::unique_ptr<TestPrefsUtil> prefs_util_; | 105 std::unique_ptr<TestPrefsUtil> prefs_util_; |
| 103 | 106 |
| 104 DISALLOW_COPY_AND_ASSIGN(TestDelegate); | 107 DISALLOW_COPY_AND_ASSIGN(TestDelegate); |
| 105 }; | 108 }; |
| 106 | 109 |
| 107 class UsersPrivateApiTest : public ExtensionApiTest { | 110 class UsersPrivateApiTest : public ExtensionApiTest { |
| 108 public: | 111 public: |
| 109 UsersPrivateApiTest() {} | 112 UsersPrivateApiTest() { |
| 113 #if defined(OS_CHROMEOS) |
| 114 // Mock owner key pairs. Note this needs to happen before |
| 115 // OwnerSettingsServiceChromeOS is created. |
| 116 scoped_refptr<ownership::MockOwnerKeyUtil> owner_key_util = |
| 117 new ownership::MockOwnerKeyUtil(); |
| 118 owner_key_util->SetPrivateKey(crypto::RSAPrivateKey::Create(512)); |
| 119 |
| 120 chromeos::OwnerSettingsServiceChromeOSFactory::GetInstance() |
| 121 ->SetOwnerKeyUtilForTesting(owner_key_util); |
| 122 #endif |
| 123 } |
| 110 ~UsersPrivateApiTest() override {} | 124 ~UsersPrivateApiTest() override {} |
| 111 | 125 |
| 112 static std::unique_ptr<KeyedService> GetUsersPrivateDelegate( | 126 static std::unique_ptr<KeyedService> GetUsersPrivateDelegate( |
| 113 content::BrowserContext* profile) { | 127 content::BrowserContext* profile) { |
| 114 CHECK(s_test_delegate_); | 128 CHECK(s_test_delegate_); |
| 115 return base::WrapUnique(s_test_delegate_); | 129 return base::WrapUnique(s_test_delegate_); |
| 116 } | 130 } |
| 117 | 131 |
| 118 void SetUpCommandLine(base::CommandLine* command_line) override { | 132 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 119 ExtensionApiTest::SetUpCommandLine(command_line); | 133 ExtensionApiTest::SetUpCommandLine(command_line); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 IN_PROC_BROWSER_TEST_F(UsersPrivateApiTest, AddAndRemoveUsers) { | 173 IN_PROC_BROWSER_TEST_F(UsersPrivateApiTest, AddAndRemoveUsers) { |
| 160 EXPECT_TRUE(RunSubtest("addAndRemoveUsers")) << message_; | 174 EXPECT_TRUE(RunSubtest("addAndRemoveUsers")) << message_; |
| 161 } | 175 } |
| 162 | 176 |
| 163 IN_PROC_BROWSER_TEST_F(UsersPrivateApiTest, IsOwner) { | 177 IN_PROC_BROWSER_TEST_F(UsersPrivateApiTest, IsOwner) { |
| 164 EXPECT_TRUE(RunSubtest("isOwner")) << message_; | 178 EXPECT_TRUE(RunSubtest("isOwner")) << message_; |
| 165 } | 179 } |
| 166 #endif | 180 #endif |
| 167 | 181 |
| 168 } // namespace extensions | 182 } // namespace extensions |
| OLD | NEW |