| OLD | NEW |
| 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 "ash/shell.h" | 5 #include "ash/shell.h" |
| 6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
| 7 #include "chrome/browser/chrome_browser_main.h" | 7 #include "chrome/browser/chrome_browser_main.h" |
| 8 #include "chrome/browser/chrome_browser_main_extra_parts.h" | 8 #include "chrome/browser/chrome_browser_main_extra_parts.h" |
| 9 #include "chrome/browser/chrome_content_browser_client.h" | 9 #include "chrome/browser/chrome_content_browser_client.h" |
| 10 #include "chrome/browser/chromeos/cros/cros_in_process_browser_test.h" | 10 #include "chrome/browser/chromeos/cros/cros_in_process_browser_test.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 #include "content/public/browser/notification_registrar.h" | 26 #include "content/public/browser/notification_registrar.h" |
| 27 #include "content/public/browser/notification_service.h" | 27 #include "content/public/browser/notification_service.h" |
| 28 #include "content/public/test/test_utils.h" | 28 #include "content/public/test/test_utils.h" |
| 29 #include "testing/gmock/include/gmock/gmock.h" | 29 #include "testing/gmock/include/gmock/gmock.h" |
| 30 #include "testing/gtest/include/gtest/gtest.h" | 30 #include "testing/gtest/include/gtest/gtest.h" |
| 31 | 31 |
| 32 using ::testing::_; | 32 using ::testing::_; |
| 33 using ::testing::AnyNumber; | 33 using ::testing::AnyNumber; |
| 34 using ::testing::Return; | 34 using ::testing::Return; |
| 35 | 35 |
| 36 namespace chromeos { | 36 namespace { |
| 37 | 37 |
| 38 class LoginTestBase : public CrosInProcessBrowserTest { | 38 class LoginTestBase : public chromeos::CrosInProcessBrowserTest { |
| 39 public: | 39 public: |
| 40 LoginTestBase() | 40 LoginTestBase() |
| 41 : mock_cryptohome_library_(NULL), | 41 : mock_cryptohome_library_(NULL), |
| 42 mock_network_library_(NULL) { | 42 mock_network_library_(NULL) { |
| 43 } | 43 } |
| 44 | 44 |
| 45 protected: | 45 protected: |
| 46 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { | 46 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { |
| 47 cros_mock_->InitStatusAreaMocks(); | 47 cros_mock_->InitStatusAreaMocks(); |
| 48 cros_mock_->SetStatusAreaMocksExpectations(); | 48 cros_mock_->SetStatusAreaMocksExpectations(); |
| 49 cros_mock_->InitMockCryptohomeLibrary(); | 49 cros_mock_->InitMockCryptohomeLibrary(); |
| 50 mock_cryptohome_library_ = cros_mock_->mock_cryptohome_library(); | 50 mock_cryptohome_library_ = cros_mock_->mock_cryptohome_library(); |
| 51 mock_network_library_ = cros_mock_->mock_network_library(); | 51 mock_network_library_ = cros_mock_->mock_network_library(); |
| 52 EXPECT_CALL(*mock_cryptohome_library_, GetSystemSalt()) | 52 EXPECT_CALL(*mock_cryptohome_library_, GetSystemSalt()) |
| 53 .WillRepeatedly(Return(std::string("stub_system_salt"))); | 53 .WillRepeatedly(Return(std::string("stub_system_salt"))); |
| 54 EXPECT_CALL(*mock_cryptohome_library_, InstallAttributesIsReady()) | 54 EXPECT_CALL(*mock_cryptohome_library_, InstallAttributesIsReady()) |
| 55 .WillRepeatedly(Return(false)); | 55 .WillRepeatedly(Return(false)); |
| 56 EXPECT_CALL(*mock_network_library_, AddUserActionObserver(_)) | 56 EXPECT_CALL(*mock_network_library_, AddUserActionObserver(_)) |
| 57 .Times(AnyNumber()); | 57 .Times(AnyNumber()); |
| 58 EXPECT_CALL(*mock_network_library_, LoadOncNetworks(_, _, _, _)) | 58 EXPECT_CALL(*mock_network_library_, LoadOncNetworks(_, _, _, _)) |
| 59 .WillRepeatedly(Return(true)); | 59 .WillRepeatedly(Return(true)); |
| 60 } | 60 } |
| 61 | 61 |
| 62 MockCryptohomeLibrary* mock_cryptohome_library_; | 62 chromeos::MockCryptohomeLibrary* mock_cryptohome_library_; |
| 63 MockNetworkLibrary* mock_network_library_; | 63 chromeos::MockNetworkLibrary* mock_network_library_; |
| 64 | 64 |
| 65 private: | 65 private: |
| 66 DISALLOW_COPY_AND_ASSIGN(LoginTestBase); | 66 DISALLOW_COPY_AND_ASSIGN(LoginTestBase); |
| 67 }; | 67 }; |
| 68 | 68 |
| 69 class LoginUserTest : public LoginTestBase { | 69 class LoginUserTest : public LoginTestBase { |
| 70 protected: | 70 protected: |
| 71 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { | 71 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { |
| 72 LoginTestBase::SetUpInProcessBrowserTestFixture(); | 72 LoginTestBase::SetUpInProcessBrowserTestFixture(); |
| 73 } | 73 } |
| 74 | 74 |
| 75 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 75 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 76 command_line->AppendSwitchASCII(switches::kLoginUser, "TestUser@gmail.com"); | 76 command_line->AppendSwitchASCII( |
| 77 command_line->AppendSwitchASCII(switches::kLoginProfile, "user"); | 77 chromeos::switches::kLoginUser, "TestUser@gmail.com"); |
| 78 command_line->AppendSwitchASCII(chromeos::switches::kLoginProfile, "user"); |
| 78 command_line->AppendSwitch(::switches::kNoFirstRun); | 79 command_line->AppendSwitch(::switches::kNoFirstRun); |
| 79 } | 80 } |
| 80 }; | 81 }; |
| 81 | 82 |
| 82 class LoginGuestTest : public LoginTestBase { | 83 class LoginGuestTest : public LoginTestBase { |
| 83 protected: | 84 protected: |
| 84 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 85 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 85 command_line->AppendSwitch(switches::kGuestSession); | 86 command_line->AppendSwitch(chromeos::switches::kGuestSession); |
| 86 command_line->AppendSwitch(::switches::kIncognito); | 87 command_line->AppendSwitch(::switches::kIncognito); |
| 87 command_line->AppendSwitchASCII(switches::kLoginProfile, "user"); | 88 command_line->AppendSwitchASCII(chromeos::switches::kLoginProfile, "user"); |
| 88 command_line->AppendSwitch(::switches::kNoFirstRun); | 89 command_line->AppendSwitch(::switches::kNoFirstRun); |
| 89 } | 90 } |
| 90 }; | 91 }; |
| 91 | 92 |
| 92 class LoginCursorTest : public LoginTestBase { | 93 class LoginCursorTest : public LoginTestBase { |
| 93 protected: | 94 protected: |
| 94 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 95 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 95 command_line->AppendSwitch(switches::kLoginManager); | 96 command_line->AppendSwitch(chromeos::switches::kLoginManager); |
| 96 } | 97 } |
| 97 }; | 98 }; |
| 98 | 99 |
| 99 // Used to add an observer to NotificationService after it's created. | 100 // Used to add an observer to NotificationService after it's created. |
| 100 class TestBrowserMainExtraParts | 101 class TestBrowserMainExtraParts |
| 101 : public ChromeBrowserMainExtraParts, | 102 : public ChromeBrowserMainExtraParts, |
| 102 public content::NotificationObserver { | 103 public content::NotificationObserver { |
| 103 public: | 104 public: |
| 104 TestBrowserMainExtraParts() {} | 105 TestBrowserMainExtraParts() {} |
| 105 virtual ~TestBrowserMainExtraParts() {} | 106 virtual ~TestBrowserMainExtraParts() {} |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 return main_parts; | 142 return main_parts; |
| 142 } | 143 } |
| 143 | 144 |
| 144 TestBrowserMainExtraParts* browser_main_extra_parts_; | 145 TestBrowserMainExtraParts* browser_main_extra_parts_; |
| 145 | 146 |
| 146 private: | 147 private: |
| 147 DISALLOW_COPY_AND_ASSIGN(TestContentBrowserClient); | 148 DISALLOW_COPY_AND_ASSIGN(TestContentBrowserClient); |
| 148 }; | 149 }; |
| 149 | 150 |
| 150 | 151 |
| 151 class LoginSigninTest : public CrosInProcessBrowserTest { | 152 class LoginSigninTest : public chromeos::CrosInProcessBrowserTest { |
| 152 protected: | 153 protected: |
| 153 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 154 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 154 command_line->AppendSwitch(switches::kLoginManager); | 155 command_line->AppendSwitch(chromeos::switches::kLoginManager); |
| 155 command_line->AppendSwitch(switches::kForceLoginManagerInTests); | 156 command_line->AppendSwitch(chromeos::switches::kForceLoginManagerInTests); |
| 156 } | 157 } |
| 157 | 158 |
| 158 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { | 159 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { |
| 159 content_browser_client_.reset(new TestContentBrowserClient()); | 160 content_browser_client_.reset(new TestContentBrowserClient()); |
| 160 original_content_browser_client_ = content::SetBrowserClientForTesting( | 161 original_content_browser_client_ = content::SetBrowserClientForTesting( |
| 161 content_browser_client_.get()); | 162 content_browser_client_.get()); |
| 162 } | 163 } |
| 163 | 164 |
| 164 virtual void TearDownInProcessBrowserTestFixture() OVERRIDE { | 165 virtual void TearDownInProcessBrowserTestFixture() OVERRIDE { |
| 165 content::SetBrowserClientForTesting(original_content_browser_client_); | 166 content::SetBrowserClientForTesting(original_content_browser_client_); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 193 } | 194 } |
| 194 | 195 |
| 195 // Verifies the cursor is not hidden at startup when running guest session. | 196 // Verifies the cursor is not hidden at startup when running guest session. |
| 196 IN_PROC_BROWSER_TEST_F(LoginGuestTest, CursorShown) { | 197 IN_PROC_BROWSER_TEST_F(LoginGuestTest, CursorShown) { |
| 197 EXPECT_TRUE(ash::Shell::GetInstance()->cursor_manager()->IsCursorVisible()); | 198 EXPECT_TRUE(ash::Shell::GetInstance()->cursor_manager()->IsCursorVisible()); |
| 198 } | 199 } |
| 199 | 200 |
| 200 // Verifies the cursor is hidden at startup on login screen. | 201 // Verifies the cursor is hidden at startup on login screen. |
| 201 IN_PROC_BROWSER_TEST_F(LoginCursorTest, CursorHidden) { | 202 IN_PROC_BROWSER_TEST_F(LoginCursorTest, CursorHidden) { |
| 202 // Login screen needs to be shown explicitly when running test. | 203 // Login screen needs to be shown explicitly when running test. |
| 203 ShowLoginWizard(WizardController::kLoginScreenName, gfx::Size()); | 204 chromeos::ShowLoginWizard(chromeos::WizardController::kLoginScreenName, |
| 205 gfx::Size()); |
| 204 | 206 |
| 205 // Cursor should be hidden at startup | 207 // Cursor should be hidden at startup |
| 206 EXPECT_FALSE(ash::Shell::GetInstance()->cursor_manager()->IsCursorVisible()); | 208 EXPECT_FALSE(ash::Shell::GetInstance()->cursor_manager()->IsCursorVisible()); |
| 207 | 209 |
| 208 // Cursor should be shown after cursor is moved. | 210 // Cursor should be shown after cursor is moved. |
| 209 EXPECT_TRUE(ui_test_utils::SendMouseMoveSync(gfx::Point())); | 211 EXPECT_TRUE(ui_test_utils::SendMouseMoveSync(gfx::Point())); |
| 210 EXPECT_TRUE(ash::Shell::GetInstance()->cursor_manager()->IsCursorVisible()); | 212 EXPECT_TRUE(ash::Shell::GetInstance()->cursor_manager()->IsCursorVisible()); |
| 211 | 213 |
| 212 MessageLoop::current()->DeleteSoon(FROM_HERE, | 214 MessageLoop::current()->DeleteSoon( |
| 213 BaseLoginDisplayHost::default_host()); | 215 FROM_HERE, chromeos::BaseLoginDisplayHost::default_host()); |
| 214 } | 216 } |
| 215 | 217 |
| 216 // Verifies that the webui for login comes up successfully. | 218 // Verifies that the webui for login comes up successfully. |
| 217 IN_PROC_BROWSER_TEST_F(LoginSigninTest, WebUIVisible) { | 219 IN_PROC_BROWSER_TEST_F(LoginSigninTest, WebUIVisible) { |
| 218 scoped_refptr<content::MessageLoopRunner> runner = | 220 scoped_refptr<content::MessageLoopRunner> runner = |
| 219 new content::MessageLoopRunner; | 221 new content::MessageLoopRunner; |
| 220 content_browser_client_->browser_main_extra_parts_->set_quit_task( | 222 content_browser_client_->browser_main_extra_parts_->set_quit_task( |
| 221 runner->QuitClosure()); | 223 runner->QuitClosure()); |
| 222 runner->Run(); | 224 runner->Run(); |
| 223 } | 225 } |
| 224 | 226 |
| 225 } // namespace chromeos | 227 } |
| OLD | NEW |