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

Side by Side Diff: chrome/browser/chromeos/login/screen_locker_browsertest.cc

Issue 10855244: Remove the --enable-device-policy and --enable-onc-policy flags. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Updated comment Created 8 years, 4 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 | Annotate | Revision Log
OLDNEW
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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/memory/scoped_ptr.h" 6 #include "base/memory/scoped_ptr.h"
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "chrome/browser/chromeos/cros/cros_in_process_browser_test.h" 8 #include "chrome/browser/chromeos/cros/cros_in_process_browser_test.h"
9 #include "chrome/browser/chromeos/cros/mock_network_library.h" 9 #include "chrome/browser/chromeos/cros/mock_network_library.h"
10 #include "chrome/browser/chromeos/login/mock_authenticator.h" 10 #include "chrome/browser/chromeos/login/mock_authenticator.h"
11 #include "chrome/browser/chromeos/login/screen_locker.h" 11 #include "chrome/browser/chromeos/login/screen_locker.h"
12 #include "chrome/browser/chromeos/login/screen_locker_tester.h" 12 #include "chrome/browser/chromeos/login/screen_locker_tester.h"
13 #include "chrome/browser/chromeos/login/user_manager.h" 13 #include "chrome/browser/chromeos/login/user_manager.h"
14 #include "chrome/browser/profiles/profile_manager.h" 14 #include "chrome/browser/profiles/profile_manager.h"
15 #include "chrome/browser/ui/browser.h" 15 #include "chrome/browser/ui/browser.h"
16 #include "chrome/browser/ui/browser_window.h" 16 #include "chrome/browser/ui/browser_window.h"
17 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h" 17 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h"
18 #include "chrome/common/chrome_notification_types.h" 18 #include "chrome/common/chrome_notification_types.h"
19 #include "chrome/common/chrome_switches.h" 19 #include "chrome/common/chrome_switches.h"
20 #include "chrome/test/base/ui_test_utils.h" 20 #include "chrome/test/base/ui_test_utils.h"
21 #include "chromeos/dbus/mock_dbus_thread_manager.h" 21 #include "chromeos/dbus/mock_dbus_thread_manager.h"
22 #include "chromeos/dbus/mock_power_manager_client.h" 22 #include "chromeos/dbus/mock_power_manager_client.h"
23 #include "content/public/browser/notification_service.h" 23 #include "content/public/browser/notification_service.h"
24 #include "testing/gmock/include/gmock/gmock.h" 24 #include "testing/gmock/include/gmock/gmock.h"
25 #include "testing/gtest/include/gtest/gtest.h" 25 #include "testing/gtest/include/gtest/gtest.h"
26 #include "ui/ui_controls/ui_controls.h" 26 #include "ui/ui_controls/ui_controls.h"
27 #include "ui/views/widget/widget.h" 27 #include "ui/views/widget/widget.h"
28 28
29 using testing::_;
30 using testing::AnyNumber;
31 using testing::Return;
32
29 namespace { 33 namespace {
30 34
31 // An object that wait for lock state and fullscreen state. 35 // An object that wait for lock state and fullscreen state.
32 class Waiter : public content::NotificationObserver { 36 class Waiter : public content::NotificationObserver {
33 public: 37 public:
34 explicit Waiter(Browser* browser) 38 explicit Waiter(Browser* browser)
35 : browser_(browser), 39 : browser_(browser),
36 running_(false) { 40 running_(false) {
37 registrar_.Add(this, 41 registrar_.Add(this,
38 chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED, 42 chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED,
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 if (!tester->IsLocked()) 103 if (!tester->IsLocked())
100 lock_state_observer.Wait(); 104 lock_state_observer.Wait();
101 EXPECT_TRUE(tester->IsLocked()); 105 EXPECT_TRUE(tester->IsLocked());
102 } 106 }
103 107
104 private: 108 private:
105 virtual void SetUpInProcessBrowserTestFixture() { 109 virtual void SetUpInProcessBrowserTestFixture() {
106 MockDBusThreadManager* mock_dbus_thread_manager = 110 MockDBusThreadManager* mock_dbus_thread_manager =
107 new MockDBusThreadManager; 111 new MockDBusThreadManager;
108 EXPECT_CALL(*mock_dbus_thread_manager, GetSystemBus()) 112 EXPECT_CALL(*mock_dbus_thread_manager, GetSystemBus())
109 .WillRepeatedly(testing::Return(reinterpret_cast<dbus::Bus*>(NULL))); 113 .WillRepeatedly(Return(reinterpret_cast<dbus::Bus*>(NULL)));
110 DBusThreadManager::InitializeForTesting(mock_dbus_thread_manager); 114 DBusThreadManager::InitializeForTesting(mock_dbus_thread_manager);
111 CrosInProcessBrowserTest::SetUpInProcessBrowserTestFixture(); 115 CrosInProcessBrowserTest::SetUpInProcessBrowserTestFixture();
112 mock_power_manager_client_ = static_cast<MockPowerManagerClient*>( 116 mock_power_manager_client_ = static_cast<MockPowerManagerClient*>(
113 DBusThreadManager::Get()->GetPowerManagerClient()); 117 DBusThreadManager::Get()->GetPowerManagerClient());
114 cros_mock_->InitStatusAreaMocks(); 118 cros_mock_->InitStatusAreaMocks();
115 EXPECT_CALL(*mock_power_manager_client_, AddObserver(testing::_)) 119 EXPECT_CALL(*mock_power_manager_client_, AddObserver(_))
116 .Times(1) 120 .Times(1)
117 .RetiresOnSaturation(); 121 .RetiresOnSaturation();
118 EXPECT_CALL(*mock_power_manager_client_, NotifyScreenUnlockCompleted()) 122 EXPECT_CALL(*mock_power_manager_client_, NotifyScreenUnlockCompleted())
119 .Times(1) 123 .Times(1)
120 .RetiresOnSaturation(); 124 .RetiresOnSaturation();
121 // Expectations for the status are on the screen lock window. 125 // Expectations for the status are on the screen lock window.
122 cros_mock_->SetStatusAreaMocksExpectations(); 126 cros_mock_->SetStatusAreaMocksExpectations();
123 MockNetworkLibrary* mock_network_library = 127 MockNetworkLibrary* mock_network_library =
124 cros_mock_->mock_network_library(); 128 cros_mock_->mock_network_library();
125 EXPECT_CALL(*mock_network_library, AddUserActionObserver(testing::_)) 129 EXPECT_CALL(*mock_network_library, AddUserActionObserver(_))
126 .Times(testing::AnyNumber()); 130 .Times(AnyNumber());
131 EXPECT_CALL(*mock_network_library, LoadOncNetworks(_, _, _, _))
132 .WillRepeatedly(Return(true));
127 } 133 }
128 134
129 virtual void SetUpCommandLine(CommandLine* command_line) { 135 virtual void SetUpCommandLine(CommandLine* command_line) {
130 command_line->AppendSwitchASCII(switches::kLoginProfile, "user"); 136 command_line->AppendSwitchASCII(switches::kLoginProfile, "user");
131 command_line->AppendSwitch(switches::kNoFirstRun); 137 command_line->AppendSwitch(switches::kNoFirstRun);
132 } 138 }
133 139
134 DISALLOW_COPY_AND_ASSIGN(ScreenLockerTest); 140 DISALLOW_COPY_AND_ASSIGN(ScreenLockerTest);
135 }; 141 };
136 142
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 content::RunAllPendingInMessageLoop(); 253 content::RunAllPendingInMessageLoop();
248 EXPECT_EQ("", tester->GetPassword()); 254 EXPECT_EQ("", tester->GetPassword());
249 255
250 // Close the locker to match expectations. 256 // Close the locker to match expectations.
251 ScreenLocker::Hide(); 257 ScreenLocker::Hide();
252 content::RunAllPendingInMessageLoop(); 258 content::RunAllPendingInMessageLoop();
253 EXPECT_FALSE(tester->IsLocked()); 259 EXPECT_FALSE(tester->IsLocked());
254 } 260 }
255 261
256 } // namespace chromeos 262 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698