| 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/common/session/session_state_delegate.h" | |
| 6 #include "ash/common/wm_shell.h" | |
| 7 #include "base/command_line.h" | 5 #include "base/command_line.h" |
| 8 #include "chrome/browser/chromeos/login/login_manager_test.h" | 6 #include "chrome/browser/chromeos/login/login_manager_test.h" |
| 9 #include "chrome/browser/chromeos/login/startup_utils.h" | 7 #include "chrome/browser/chromeos/login/startup_utils.h" |
| 10 #include "chrome/browser/profiles/profile_manager.h" | 8 #include "chrome/browser/profiles/profile_manager.h" |
| 11 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
| 12 #include "chrome/browser/ui/browser_finder.h" | 10 #include "chrome/browser/ui/browser_finder.h" |
| 13 #include "chrome/browser/ui/browser_window.h" | 11 #include "chrome/browser/ui/browser_window.h" |
| 14 #include "chrome/browser/ui/view_ids.h" | 12 #include "chrome/browser/ui/view_ids.h" |
| 15 #include "chrome/common/chrome_switches.h" | 13 #include "chrome/common/chrome_switches.h" |
| 14 #include "components/session_manager/core/session_manager.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 17 #include "ui/views/focus/focus_manager.h" | 16 #include "ui/views/focus/focus_manager.h" |
| 18 #include "ui/views/view.h" | 17 #include "ui/views/view.h" |
| 19 #include "ui/views/widget/widget.h" | 18 #include "ui/views/widget/widget.h" |
| 20 | 19 |
| 21 namespace chromeos { | 20 namespace chromeos { |
| 22 | 21 |
| 23 namespace { | 22 namespace { |
| 24 | 23 |
| 25 const char kTestUser[] = "test-user@gmail.com"; | 24 const char kTestUser[] = "test-user@gmail.com"; |
| 26 | 25 |
| 27 } // namespace | 26 } // namespace |
| 28 | 27 |
| 29 class BrowserLoginTest : public chromeos::LoginManagerTest { | 28 class BrowserLoginTest : public chromeos::LoginManagerTest { |
| 30 public: | 29 public: |
| 31 BrowserLoginTest() : LoginManagerTest(true) {} | 30 BrowserLoginTest() : LoginManagerTest(true) {} |
| 32 ~BrowserLoginTest() override {} | 31 ~BrowserLoginTest() override {} |
| 33 | 32 |
| 34 void SetUpCommandLine(base::CommandLine* command_line) override { | 33 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 35 LoginManagerTest::SetUpCommandLine(command_line); | 34 LoginManagerTest::SetUpCommandLine(command_line); |
| 36 command_line->AppendSwitch(::switches::kCreateBrowserOnStartupForTests); | 35 command_line->AppendSwitch(::switches::kCreateBrowserOnStartupForTests); |
| 37 } | 36 } |
| 38 }; | 37 }; |
| 39 | 38 |
| 40 IN_PROC_BROWSER_TEST_F(BrowserLoginTest, PRE_BrowserActive) { | 39 IN_PROC_BROWSER_TEST_F(BrowserLoginTest, PRE_BrowserActive) { |
| 41 RegisterUser(kTestUser); | 40 RegisterUser(kTestUser); |
| 42 EXPECT_EQ(session_manager::SessionState::LOGIN_PRIMARY, | 41 EXPECT_EQ(session_manager::SessionState::OOBE, |
| 43 ash::WmShell::Get()->GetSessionStateDelegate()->GetSessionState()); | 42 session_manager::SessionManager::Get()->session_state()); |
| 44 chromeos::StartupUtils::MarkOobeCompleted(); | 43 chromeos::StartupUtils::MarkOobeCompleted(); |
| 45 } | 44 } |
| 46 | 45 |
| 47 IN_PROC_BROWSER_TEST_F(BrowserLoginTest, BrowserActive) { | 46 IN_PROC_BROWSER_TEST_F(BrowserLoginTest, BrowserActive) { |
| 48 EXPECT_EQ(session_manager::SessionState::LOGIN_PRIMARY, | 47 EXPECT_EQ(session_manager::SessionState::LOGIN_PRIMARY, |
| 49 ash::WmShell::Get()->GetSessionStateDelegate()->GetSessionState()); | 48 session_manager::SessionManager::Get()->session_state()); |
| 50 LoginUser(kTestUser); | 49 LoginUser(kTestUser); |
| 51 EXPECT_EQ(session_manager::SessionState::ACTIVE, | 50 EXPECT_EQ(session_manager::SessionState::ACTIVE, |
| 52 ash::WmShell::Get()->GetSessionStateDelegate()->GetSessionState()); | 51 session_manager::SessionManager::Get()->session_state()); |
| 53 | 52 |
| 54 Browser* browser = | 53 Browser* browser = |
| 55 chrome::FindAnyBrowser(ProfileManager::GetActiveUserProfile(), false); | 54 chrome::FindAnyBrowser(ProfileManager::GetActiveUserProfile(), false); |
| 56 EXPECT_TRUE(browser != NULL); | 55 EXPECT_TRUE(browser != NULL); |
| 57 EXPECT_TRUE(browser->window()->IsActive()); | 56 EXPECT_TRUE(browser->window()->IsActive()); |
| 58 | 57 |
| 59 gfx::NativeWindow window = browser->window()->GetNativeWindow(); | 58 gfx::NativeWindow window = browser->window()->GetNativeWindow(); |
| 60 views::Widget* widget = views::Widget::GetWidgetForNativeWindow(window); | 59 views::Widget* widget = views::Widget::GetWidgetForNativeWindow(window); |
| 61 views::FocusManager* focus_manager = widget->GetFocusManager(); | 60 views::FocusManager* focus_manager = widget->GetFocusManager(); |
| 62 EXPECT_TRUE(focus_manager != NULL); | 61 EXPECT_TRUE(focus_manager != NULL); |
| 63 | 62 |
| 64 const views::View* focused_view = focus_manager->GetFocusedView(); | 63 const views::View* focused_view = focus_manager->GetFocusedView(); |
| 65 EXPECT_TRUE(focused_view != NULL); | 64 EXPECT_TRUE(focused_view != NULL); |
| 66 EXPECT_EQ(VIEW_ID_OMNIBOX, focused_view->id()); | 65 EXPECT_EQ(VIEW_ID_OMNIBOX, focused_view->id()); |
| 67 } | 66 } |
| 68 | 67 |
| 69 } // namespace chromeos | 68 } // namespace chromeos |
| OLD | NEW |