| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/session/session_state_delegate.h" | 5 #include "ash/session/session_state_delegate.h" |
| 6 #include "ash/shell.h" | 6 #include "ash/shell.h" |
| 7 #include "chrome/browser/chromeos/login/login_manager_test.h" | 7 #include "chrome/browser/chromeos/login/login_manager_test_helper.h" |
| 8 #include "chrome/browser/chromeos/login/startup_utils.h" | 8 #include "chrome/browser/chromeos/login/startup_utils.h" |
| 9 #include "chrome/browser/profiles/profile_manager.h" | 9 #include "chrome/browser/profiles/profile_manager.h" |
| 10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
| 11 #include "chrome/browser/ui/browser_finder.h" | 11 #include "chrome/browser/ui/browser_finder.h" |
| 12 #include "chrome/browser/ui/browser_window.h" | 12 #include "chrome/browser/ui/browser_window.h" |
| 13 #include "chrome/browser/ui/view_ids.h" | 13 #include "chrome/browser/ui/view_ids.h" |
| 14 #include "chrome/common/chrome_switches.h" | 14 #include "chrome/common/chrome_switches.h" |
| 15 #include "chrome/test/base/in_process_browser_test.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 16 #include "ui/views/focus/focus_manager.h" | 17 #include "ui/views/focus/focus_manager.h" |
| 17 #include "ui/views/view.h" | 18 #include "ui/views/view.h" |
| 18 | 19 |
| 19 namespace chromeos { | 20 namespace chromeos { |
| 20 | 21 |
| 21 namespace { | 22 namespace { |
| 22 | 23 |
| 23 const char kTestUser[] = "test-user@gmail.com"; | 24 const char kTestUser[] = "test-user@gmail.com"; |
| 24 | 25 |
| 25 } // anonymous namespace | 26 } // anonymous namespace |
| 26 | 27 |
| 27 class BrowserLoginTest : public chromeos::LoginManagerTest { | 28 class BrowserLoginTest : public InProcessBrowserTest { |
| 28 public: | 29 public: |
| 29 BrowserLoginTest() : LoginManagerTest(true) {} | 30 BrowserLoginTest() : login_manager_test_helper_(new LoginManagerTestHelper) { |
| 31 set_exit_when_last_browser_closes(false); |
| 32 } |
| 33 |
| 30 virtual ~BrowserLoginTest() {} | 34 virtual ~BrowserLoginTest() {} |
| 31 | 35 |
| 36 virtual void SetUpOnMainThread() OVERRIDE { |
| 37 login_manager_test_helper_->SetUp(); |
| 38 } |
| 39 |
| 32 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 40 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 33 LoginManagerTest::SetUpCommandLine(command_line); | 41 login_manager_test_helper_->SetUpCommandLine(command_line); |
| 34 command_line->AppendSwitch(::switches::kCreateBrowserOnStartupForTests); | 42 command_line->AppendSwitch(::switches::kCreateBrowserOnStartupForTests); |
| 35 } | 43 } |
| 44 |
| 45 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { |
| 46 login_manager_test_helper_->SetUpLoginUtils(true); |
| 47 } |
| 48 |
| 49 virtual void CleanUpOnMainThread() OVERRIDE { |
| 50 login_manager_test_helper_->CleanUp(); |
| 51 } |
| 52 |
| 53 protected: |
| 54 scoped_ptr<LoginManagerTestHelper> login_manager_test_helper_; |
| 36 }; | 55 }; |
| 37 | 56 |
| 38 IN_PROC_BROWSER_TEST_F(BrowserLoginTest, PRE_BrowserActive) { | 57 IN_PROC_BROWSER_TEST_F(BrowserLoginTest, PRE_BrowserActive) { |
| 39 RegisterUser(kTestUser); | 58 login_manager_test_helper_->RegisterUser(kTestUser); |
| 40 EXPECT_EQ(ash::SessionStateDelegate::SESSION_STATE_LOGIN_PRIMARY, | 59 EXPECT_EQ(ash::SessionStateDelegate::SESSION_STATE_LOGIN_PRIMARY, |
| 41 ash::Shell::GetInstance()->session_state_delegate()-> | 60 ash::Shell::GetInstance()->session_state_delegate()-> |
| 42 GetSessionState()); | 61 GetSessionState()); |
| 43 chromeos::StartupUtils::MarkOobeCompleted(); | 62 chromeos::StartupUtils::MarkOobeCompleted(); |
| 44 } | 63 } |
| 45 | 64 |
| 46 IN_PROC_BROWSER_TEST_F(BrowserLoginTest, BrowserActive) { | 65 IN_PROC_BROWSER_TEST_F(BrowserLoginTest, BrowserActive) { |
| 47 EXPECT_EQ(ash::SessionStateDelegate::SESSION_STATE_LOGIN_PRIMARY, | 66 EXPECT_EQ(ash::SessionStateDelegate::SESSION_STATE_LOGIN_PRIMARY, |
| 48 ash::Shell::GetInstance()->session_state_delegate()-> | 67 ash::Shell::GetInstance()->session_state_delegate()-> |
| 49 GetSessionState()); | 68 GetSessionState()); |
| 50 LoginUser(kTestUser); | 69 login_manager_test_helper_->LogInUser(kTestUser); |
| 51 EXPECT_EQ(ash::SessionStateDelegate::SESSION_STATE_ACTIVE, | 70 EXPECT_EQ(ash::SessionStateDelegate::SESSION_STATE_ACTIVE, |
| 52 ash::Shell::GetInstance()->session_state_delegate()-> | 71 ash::Shell::GetInstance()->session_state_delegate()-> |
| 53 GetSessionState()); | 72 GetSessionState()); |
| 54 | 73 |
| 55 Browser* browser = FindAnyBrowser(ProfileManager::GetActiveUserProfile(), | 74 Browser* browser = FindAnyBrowser(ProfileManager::GetActiveUserProfile(), |
| 56 false, | 75 false, |
| 57 chrome::HOST_DESKTOP_TYPE_ASH); | 76 chrome::HOST_DESKTOP_TYPE_ASH); |
| 58 EXPECT_TRUE(browser != NULL); | 77 EXPECT_TRUE(browser != NULL); |
| 59 EXPECT_TRUE(browser->window()->IsActive()); | 78 EXPECT_TRUE(browser->window()->IsActive()); |
| 60 | 79 |
| 61 views::FocusManager* focus_manager = browser->window()-> | 80 views::FocusManager* focus_manager = browser->window()-> |
| 62 GetBrowserWindowTesting()->GetTabContentsContainerView()-> | 81 GetBrowserWindowTesting()->GetTabContentsContainerView()-> |
| 63 GetFocusManager(); | 82 GetFocusManager(); |
| 64 EXPECT_TRUE(focus_manager != NULL); | 83 EXPECT_TRUE(focus_manager != NULL); |
| 65 | 84 |
| 66 const views::View* focused_view = focus_manager->GetFocusedView(); | 85 const views::View* focused_view = focus_manager->GetFocusedView(); |
| 67 EXPECT_TRUE(focused_view != NULL); | 86 EXPECT_TRUE(focused_view != NULL); |
| 68 EXPECT_EQ(VIEW_ID_OMNIBOX, focused_view->id()); | 87 EXPECT_EQ(VIEW_ID_OMNIBOX, focused_view->id()); |
| 69 } | 88 } |
| 70 | 89 |
| 71 } // namespace chromeos | 90 } // namespace chromeos |
| OLD | NEW |