| 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" | |
| 8 #include "chrome/browser/chrome_browser_main_extra_parts.h" | |
| 9 #include "chrome/browser/chrome_content_browser_client.h" | |
| 10 #include "chrome/browser/chrome_notification_types.h" | 7 #include "chrome/browser/chrome_notification_types.h" |
| 11 #include "chrome/browser/chromeos/login/login_display_host_impl.h" | 8 #include "chrome/browser/chromeos/login/login_display_host_impl.h" |
| 12 #include "chrome/browser/chromeos/login/login_wizard.h" | 9 #include "chrome/browser/chromeos/login/login_wizard.h" |
| 13 #include "chrome/browser/chromeos/login/user_manager.h" | 10 #include "chrome/browser/chromeos/login/user_manager.h" |
| 14 #include "chrome/browser/chromeos/login/wizard_controller.h" | 11 #include "chrome/browser/chromeos/login/wizard_controller.h" |
| 15 #include "chrome/browser/profiles/profile_manager.h" | 12 #include "chrome/browser/profiles/profile_manager.h" |
| 16 #include "chrome/browser/ui/browser.h" | 13 #include "chrome/browser/ui/browser.h" |
| 17 #include "chrome/common/chrome_constants.h" | 14 #include "chrome/common/chrome_constants.h" |
| 18 #include "chrome/common/chrome_switches.h" | 15 #include "chrome/common/chrome_switches.h" |
| 19 #include "chrome/test/base/in_process_browser_test.h" | 16 #include "chrome/test/base/in_process_browser_test.h" |
| 20 #include "chrome/test/base/interactive_test_utils.h" | 17 #include "chrome/test/base/interactive_test_utils.h" |
| 18 #include "chrome/test/base/tracing.h" |
| 21 #include "chrome/test/base/ui_test_utils.h" | 19 #include "chrome/test/base/ui_test_utils.h" |
| 22 #include "chromeos/chromeos_switches.h" | 20 #include "chromeos/chromeos_switches.h" |
| 23 #include "content/public/browser/notification_observer.h" | |
| 24 #include "content/public/browser/notification_registrar.h" | |
| 25 #include "content/public/browser/notification_service.h" | |
| 26 #include "content/public/test/test_utils.h" | 21 #include "content/public/test/test_utils.h" |
| 27 #include "extensions/browser/extension_system.h" | 22 #include "extensions/browser/extension_system.h" |
| 28 #include "testing/gmock/include/gmock/gmock.h" | 23 #include "testing/gmock/include/gmock/gmock.h" |
| 29 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
| 30 | 25 |
| 31 using ::testing::_; | 26 using ::testing::_; |
| 32 using ::testing::AnyNumber; | 27 using ::testing::AnyNumber; |
| 33 using ::testing::Return; | 28 using ::testing::Return; |
| 34 | 29 |
| 35 namespace { | 30 namespace { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 60 } | 55 } |
| 61 }; | 56 }; |
| 62 | 57 |
| 63 class LoginCursorTest : public InProcessBrowserTest { | 58 class LoginCursorTest : public InProcessBrowserTest { |
| 64 protected: | 59 protected: |
| 65 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 60 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 66 command_line->AppendSwitch(chromeos::switches::kLoginManager); | 61 command_line->AppendSwitch(chromeos::switches::kLoginManager); |
| 67 } | 62 } |
| 68 }; | 63 }; |
| 69 | 64 |
| 70 // Used to add an observer to NotificationService after it's created. | |
| 71 class TestBrowserMainExtraParts | |
| 72 : public ChromeBrowserMainExtraParts, | |
| 73 public content::NotificationObserver { | |
| 74 public: | |
| 75 TestBrowserMainExtraParts() {} | |
| 76 virtual ~TestBrowserMainExtraParts() {} | |
| 77 | |
| 78 // ChromeBrowserMainExtraParts implementation. | |
| 79 virtual void PreEarlyInitialization() OVERRIDE { | |
| 80 registrar_.Add(this, chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, | |
| 81 content::NotificationService::AllSources()); | |
| 82 } | |
| 83 | |
| 84 void set_quit_task(const base::Closure& quit_task) { quit_task_ = quit_task; } | |
| 85 | |
| 86 private: | |
| 87 // Overridden from content::NotificationObserver: | |
| 88 virtual void Observe(int type, | |
| 89 const content::NotificationSource& source, | |
| 90 const content::NotificationDetails& details) OVERRIDE { | |
| 91 quit_task_.Run(); | |
| 92 } | |
| 93 | |
| 94 content::NotificationRegistrar registrar_; | |
| 95 base::Closure quit_task_; | |
| 96 | |
| 97 DISALLOW_COPY_AND_ASSIGN(TestBrowserMainExtraParts); | |
| 98 }; | |
| 99 | |
| 100 class TestContentBrowserClient : public chrome::ChromeContentBrowserClient { | |
| 101 public: | |
| 102 TestContentBrowserClient() {} | |
| 103 virtual ~TestContentBrowserClient() {} | |
| 104 | |
| 105 virtual content::BrowserMainParts* CreateBrowserMainParts( | |
| 106 const content::MainFunctionParams& parameters) OVERRIDE { | |
| 107 ChromeBrowserMainParts* main_parts = static_cast<ChromeBrowserMainParts*>( | |
| 108 ChromeContentBrowserClient::CreateBrowserMainParts(parameters)); | |
| 109 | |
| 110 browser_main_extra_parts_ = new TestBrowserMainExtraParts(); | |
| 111 main_parts->AddParts(browser_main_extra_parts_); | |
| 112 return main_parts; | |
| 113 } | |
| 114 | |
| 115 TestBrowserMainExtraParts* browser_main_extra_parts_; | |
| 116 | |
| 117 private: | |
| 118 DISALLOW_COPY_AND_ASSIGN(TestContentBrowserClient); | |
| 119 }; | |
| 120 | |
| 121 | |
| 122 class LoginSigninTest : public InProcessBrowserTest { | 65 class LoginSigninTest : public InProcessBrowserTest { |
| 123 protected: | 66 protected: |
| 124 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 67 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 125 command_line->AppendSwitch(chromeos::switches::kLoginManager); | 68 command_line->AppendSwitch(chromeos::switches::kLoginManager); |
| 126 command_line->AppendSwitch(chromeos::switches::kForceLoginManagerInTests); | 69 command_line->AppendSwitch(chromeos::switches::kForceLoginManagerInTests); |
| 127 } | 70 } |
| 128 | 71 |
| 129 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { | 72 virtual void SetUpOnMainThread() OVERRIDE { |
| 130 content_browser_client_.reset(new TestContentBrowserClient()); | 73 ASSERT_TRUE(tracing::BeginTracingWithWatch("ui", "ui", "ShowLoginWebUI", 1))
; |
| 131 original_content_browser_client_ = content::SetBrowserClientForTesting( | |
| 132 content_browser_client_.get()); | |
| 133 } | 74 } |
| 134 | |
| 135 virtual void TearDownInProcessBrowserTestFixture() OVERRIDE { | |
| 136 content::SetBrowserClientForTesting(original_content_browser_client_); | |
| 137 } | |
| 138 | |
| 139 scoped_ptr<TestContentBrowserClient> content_browser_client_; | |
| 140 content::ContentBrowserClient* original_content_browser_client_; | |
| 141 }; | 75 }; |
| 142 | 76 |
| 143 // After a chrome crash, the session manager will restart chrome with | 77 // After a chrome crash, the session manager will restart chrome with |
| 144 // the -login-user flag indicating that the user is already logged in. | 78 // the -login-user flag indicating that the user is already logged in. |
| 145 // This profile should NOT be an OTR profile. | 79 // This profile should NOT be an OTR profile. |
| 146 IN_PROC_BROWSER_TEST_P(LoginUserTest, UserPassed) { | 80 IN_PROC_BROWSER_TEST_P(LoginUserTest, UserPassed) { |
| 147 Profile* profile = browser()->profile(); | 81 Profile* profile = browser()->profile(); |
| 148 std::string profile_base_path("user"); | 82 std::string profile_base_path("user"); |
| 149 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kMultiProfiles)) | 83 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kMultiProfiles)) |
| 150 profile_base_path.insert(0, chrome::kProfileDirPrefix); | 84 profile_base_path.insert(0, chrome::kProfileDirPrefix); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 181 // Cursor should be shown after cursor is moved. | 115 // Cursor should be shown after cursor is moved. |
| 182 EXPECT_TRUE(ui_test_utils::SendMouseMoveSync(gfx::Point())); | 116 EXPECT_TRUE(ui_test_utils::SendMouseMoveSync(gfx::Point())); |
| 183 EXPECT_TRUE(ash::Shell::GetInstance()->cursor_manager()->IsCursorVisible()); | 117 EXPECT_TRUE(ash::Shell::GetInstance()->cursor_manager()->IsCursorVisible()); |
| 184 | 118 |
| 185 base::MessageLoop::current()->DeleteSoon( | 119 base::MessageLoop::current()->DeleteSoon( |
| 186 FROM_HERE, chromeos::LoginDisplayHostImpl::default_host()); | 120 FROM_HERE, chromeos::LoginDisplayHostImpl::default_host()); |
| 187 } | 121 } |
| 188 | 122 |
| 189 // Verifies that the webui for login comes up successfully. | 123 // Verifies that the webui for login comes up successfully. |
| 190 IN_PROC_BROWSER_TEST_F(LoginSigninTest, WebUIVisible) { | 124 IN_PROC_BROWSER_TEST_F(LoginSigninTest, WebUIVisible) { |
| 191 scoped_refptr<content::MessageLoopRunner> runner = | 125 base::TimeDelta no_timeout; |
| 192 new content::MessageLoopRunner; | 126 EXPECT_TRUE(tracing::WaitForWatchEvent(no_timeout)); |
| 193 content_browser_client_->browser_main_extra_parts_->set_quit_task( | 127 std::string json_events; |
| 194 runner->QuitClosure()); | 128 ASSERT_TRUE(tracing::EndTracing(&json_events)); |
| 195 runner->Run(); | |
| 196 } | 129 } |
| 197 | 130 |
| 198 INSTANTIATE_TEST_CASE_P(LoginUserTestInstantiation, | 131 INSTANTIATE_TEST_CASE_P(LoginUserTestInstantiation, |
| 199 LoginUserTest, | 132 LoginUserTest, |
| 200 testing::Bool()); | 133 testing::Bool()); |
| 201 | 134 |
| 202 INSTANTIATE_TEST_CASE_P(LoginGuestTestInstantiation, | 135 INSTANTIATE_TEST_CASE_P(LoginGuestTestInstantiation, |
| 203 LoginGuestTest, | 136 LoginGuestTest, |
| 204 testing::Bool()); | 137 testing::Bool()); |
| 205 | 138 |
| 206 } // namespace | 139 } // namespace |
| OLD | NEW |