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

Side by Side Diff: chrome/browser/chromeos/policy/display_rotation_default_handler_browsertest.cc

Issue 1870793002: Convert //chrome/browser/chromeos from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 8 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
OLDNEW
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 "chrome/browser/chromeos/policy/display_rotation_default_handler.h"
6
5 #include <stdint.h> 7 #include <stdint.h>
6 8
9 #include <memory>
10
7 #include "ash/display/display_manager.h" 11 #include "ash/display/display_manager.h"
8 #include "ash/shell.h" 12 #include "ash/shell.h"
9 #include "base/bind.h" 13 #include "base/bind.h"
10 #include "base/command_line.h" 14 #include "base/command_line.h"
11 #include "base/location.h" 15 #include "base/location.h"
12 #include "base/macros.h" 16 #include "base/macros.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/message_loop/message_loop.h" 17 #include "base/message_loop/message_loop.h"
15 #include "base/run_loop.h" 18 #include "base/run_loop.h"
16 #include "chrome/browser/chromeos/login/ui/login_display_host.h" 19 #include "chrome/browser/chromeos/login/ui/login_display_host.h"
17 #include "chrome/browser/chromeos/policy/device_policy_builder.h" 20 #include "chrome/browser/chromeos/policy/device_policy_builder.h"
18 #include "chrome/browser/chromeos/policy/device_policy_cros_browser_test.h" 21 #include "chrome/browser/chromeos/policy/device_policy_cros_browser_test.h"
19 #include "chrome/browser/chromeos/policy/display_rotation_default_handler.h"
20 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" 22 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h"
21 #include "chrome/browser/chromeos/settings/cros_settings.h" 23 #include "chrome/browser/chromeos/settings/cros_settings.h"
22 #include "chrome/browser/lifetime/application_lifetime.h" 24 #include "chrome/browser/lifetime/application_lifetime.h"
23 #include "chrome/test/base/in_process_browser_test.h" 25 #include "chrome/test/base/in_process_browser_test.h"
24 #include "chromeos/chromeos_switches.h" 26 #include "chromeos/chromeos_switches.h"
25 #include "chromeos/dbus/cryptohome_client.h" 27 #include "chromeos/dbus/cryptohome_client.h"
26 #include "chromeos/dbus/dbus_thread_manager.h" 28 #include "chromeos/dbus/dbus_thread_manager.h"
27 #include "chromeos/dbus/fake_cryptohome_client.h" 29 #include "chromeos/dbus/fake_cryptohome_client.h"
28 #include "chromeos/dbus/fake_session_manager_client.h" 30 #include "chromeos/dbus/fake_session_manager_client.h"
29 #include "chromeos/dbus/session_manager_client.h" 31 #include "chromeos/dbus/session_manager_client.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 // Creates second display if there is none yet, or removes it if there is one. 122 // Creates second display if there is none yet, or removes it if there is one.
121 void ToggleSecondDisplay() { 123 void ToggleSecondDisplay() {
122 GetDisplayManager()->AddRemoveDisplay(); 124 GetDisplayManager()->AddRemoveDisplay();
123 base::RunLoop run_loop; 125 base::RunLoop run_loop;
124 run_loop.RunUntilIdle(); 126 run_loop.RunUntilIdle();
125 } 127 }
126 128
127 void RefreshPolicyAndWaitUntilDeviceSettingsUpdated() { 129 void RefreshPolicyAndWaitUntilDeviceSettingsUpdated() {
128 base::RunLoop run_loop; 130 base::RunLoop run_loop;
129 // For calls from SetPolicy(). 131 // For calls from SetPolicy().
130 scoped_ptr<chromeos::CrosSettings::ObserverSubscription> observer = 132 std::unique_ptr<chromeos::CrosSettings::ObserverSubscription> observer =
131 chromeos::CrosSettings::Get()->AddSettingsObserver( 133 chromeos::CrosSettings::Get()->AddSettingsObserver(
132 chromeos::kDisplayRotationDefault, run_loop.QuitClosure()); 134 chromeos::kDisplayRotationDefault, run_loop.QuitClosure());
133 // For calls from SetADifferentPolicy(). 135 // For calls from SetADifferentPolicy().
134 scoped_ptr<chromeos::CrosSettings::ObserverSubscription> observer2 = 136 std::unique_ptr<chromeos::CrosSettings::ObserverSubscription> observer2 =
135 chromeos::CrosSettings::Get()->AddSettingsObserver( 137 chromeos::CrosSettings::Get()->AddSettingsObserver(
136 chromeos::kSystemUse24HourClock, run_loop.QuitClosure()); 138 chromeos::kSystemUse24HourClock, run_loop.QuitClosure());
137 RefreshDevicePolicy(); 139 RefreshDevicePolicy();
138 run_loop.Run(); 140 run_loop.Run();
139 } 141 }
140 142
141 private: 143 private:
142 DISALLOW_COPY_AND_ASSIGN(DisplayRotationDefaultTest); 144 DISALLOW_COPY_AND_ASSIGN(DisplayRotationDefaultTest);
143 }; 145 };
144 146
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 class DisplayRotationBootTest 261 class DisplayRotationBootTest
260 : public InProcessBrowserTest, 262 : public InProcessBrowserTest,
261 public testing::WithParamInterface<gfx::Display::Rotation> { 263 public testing::WithParamInterface<gfx::Display::Rotation> {
262 protected: 264 protected:
263 DisplayRotationBootTest() 265 DisplayRotationBootTest()
264 : fake_session_manager_client_(new chromeos::FakeSessionManagerClient) {} 266 : fake_session_manager_client_(new chromeos::FakeSessionManagerClient) {}
265 ~DisplayRotationBootTest() override {} 267 ~DisplayRotationBootTest() override {}
266 268
267 void SetUpInProcessBrowserTestFixture() override { 269 void SetUpInProcessBrowserTestFixture() override {
268 chromeos::DBusThreadManager::GetSetterForTesting()->SetSessionManagerClient( 270 chromeos::DBusThreadManager::GetSetterForTesting()->SetSessionManagerClient(
269 scoped_ptr<chromeos::SessionManagerClient>( 271 std::unique_ptr<chromeos::SessionManagerClient>(
270 fake_session_manager_client_)); 272 fake_session_manager_client_));
271 chromeos::DBusThreadManager::GetSetterForTesting()->SetCryptohomeClient( 273 chromeos::DBusThreadManager::GetSetterForTesting()->SetCryptohomeClient(
272 scoped_ptr<chromeos::CryptohomeClient>( 274 std::unique_ptr<chromeos::CryptohomeClient>(
273 new chromeos::FakeCryptohomeClient)); 275 new chromeos::FakeCryptohomeClient));
274 276
275 test_helper_.InstallOwnerKey(); 277 test_helper_.InstallOwnerKey();
276 test_helper_.MarkAsEnterpriseOwned(); 278 test_helper_.MarkAsEnterpriseOwned();
277 } 279 }
278 280
279 chromeos::FakeSessionManagerClient* fake_session_manager_client_; 281 chromeos::FakeSessionManagerClient* fake_session_manager_client_;
280 policy::DevicePolicyCrosTestHelper test_helper_; 282 policy::DevicePolicyCrosTestHelper test_helper_;
281 }; 283 };
282 284
283 IN_PROC_BROWSER_TEST_P(DisplayRotationBootTest, PRE_Reboot) { 285 IN_PROC_BROWSER_TEST_P(DisplayRotationBootTest, PRE_Reboot) {
284 const gfx::Display::Rotation policy_rotation = GetParam(); 286 const gfx::Display::Rotation policy_rotation = GetParam();
285 const gfx::Display::Rotation user_rotation = gfx::Display::ROTATE_180; 287 const gfx::Display::Rotation user_rotation = gfx::Display::ROTATE_180;
286 288
287 // Set policy. 289 // Set policy.
288 policy::DevicePolicyBuilder* const device_policy( 290 policy::DevicePolicyBuilder* const device_policy(
289 test_helper_.device_policy()); 291 test_helper_.device_policy());
290 em::ChromeDeviceSettingsProto& proto(device_policy->payload()); 292 em::ChromeDeviceSettingsProto& proto(device_policy->payload());
291 proto.mutable_display_rotation_default()->set_display_rotation_default( 293 proto.mutable_display_rotation_default()->set_display_rotation_default(
292 static_cast<em::DisplayRotationDefaultProto::Rotation>(policy_rotation)); 294 static_cast<em::DisplayRotationDefaultProto::Rotation>(policy_rotation));
293 base::RunLoop run_loop; 295 base::RunLoop run_loop;
294 scoped_ptr<chromeos::CrosSettings::ObserverSubscription> observer = 296 std::unique_ptr<chromeos::CrosSettings::ObserverSubscription> observer =
295 chromeos::CrosSettings::Get()->AddSettingsObserver( 297 chromeos::CrosSettings::Get()->AddSettingsObserver(
296 chromeos::kDisplayRotationDefault, run_loop.QuitClosure()); 298 chromeos::kDisplayRotationDefault, run_loop.QuitClosure());
297 device_policy->SetDefaultSigningKey(); 299 device_policy->SetDefaultSigningKey();
298 device_policy->Build(); 300 device_policy->Build();
299 fake_session_manager_client_->set_device_policy(device_policy->GetBlob()); 301 fake_session_manager_client_->set_device_policy(device_policy->GetBlob());
300 fake_session_manager_client_->OnPropertyChangeComplete(true); 302 fake_session_manager_client_->OnPropertyChangeComplete(true);
301 run_loop.Run(); 303 run_loop.Run();
302 304
303 // Check the display's rotation. 305 // Check the display's rotation.
304 ash::DisplayManager* const display_manager = GetDisplayManager(); 306 ash::DisplayManager* const display_manager = GetDisplayManager();
(...skipping 17 matching lines...) Expand all
322 } 324 }
323 325
324 INSTANTIATE_TEST_CASE_P(PolicyDisplayRotationDefault, 326 INSTANTIATE_TEST_CASE_P(PolicyDisplayRotationDefault,
325 DisplayRotationBootTest, 327 DisplayRotationBootTest,
326 testing::Values(gfx::Display::ROTATE_0, 328 testing::Values(gfx::Display::ROTATE_0,
327 gfx::Display::ROTATE_90, 329 gfx::Display::ROTATE_90,
328 gfx::Display::ROTATE_180, 330 gfx::Display::ROTATE_180,
329 gfx::Display::ROTATE_270)); 331 gfx::Display::ROTATE_270));
330 332
331 } // namespace policy 333 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698