OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/time.h" | 6 #include "base/time.h" |
7 #include "chrome/browser/chromeos/cros/cros_in_process_browser_test.h" | 7 #include "chrome/browser/chromeos/cros/cros_in_process_browser_test.h" |
8 #include "chrome/browser/chromeos/cros/mock_cryptohome_library.h" | 8 #include "chrome/browser/chromeos/cros/mock_cryptohome_library.h" |
9 #include "chrome/browser/chromeos/cros/mock_library_loader.h" | 9 #include "chrome/browser/chromeos/cros/mock_library_loader.h" |
10 #include "chrome/browser/chromeos/cros/mock_network_library.h" | 10 #include "chrome/browser/chromeos/cros/mock_network_library.h" |
11 #include "chrome/browser/chromeos/cros/mock_screen_lock_library.h" | 11 #include "chrome/browser/chromeos/dbus/mock_power_manager_client.h" |
12 #include "chrome/browser/profiles/profile_manager.h" | 12 #include "chrome/browser/profiles/profile_manager.h" |
13 #include "chrome/browser/ui/browser.h" | 13 #include "chrome/browser/ui/browser.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 "chrome/test/base/in_process_browser_test.h" |
16 #include "chrome/test/base/ui_test_utils.h" | 16 #include "chrome/test/base/ui_test_utils.h" |
17 #include "testing/gmock/include/gmock/gmock.h" | 17 #include "testing/gmock/include/gmock/gmock.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
19 | 19 |
20 namespace chromeos { | 20 namespace chromeos { |
21 using ::testing::_; | 21 using ::testing::_; |
22 using ::testing::AtLeast; | 22 using ::testing::AtLeast; |
23 using ::testing::Return; | 23 using ::testing::Return; |
24 | 24 |
25 class LoginTestBase : public CrosInProcessBrowserTest { | 25 class LoginTestBase : public CrosInProcessBrowserTest { |
26 public: | 26 public: |
27 LoginTestBase() : mock_cryptohome_library_(NULL), | 27 LoginTestBase() : mock_cryptohome_library_(NULL) { |
28 mock_screen_lock_library_(NULL) { | |
29 } | 28 } |
30 | 29 |
31 protected: | 30 protected: |
32 virtual void SetUpInProcessBrowserTestFixture() { | 31 virtual void SetUpInProcessBrowserTestFixture() { |
33 cros_mock_->InitStatusAreaMocks(); | 32 cros_mock_->InitStatusAreaMocks(); |
34 cros_mock_->SetStatusAreaMocksExpectations(); | 33 cros_mock_->SetStatusAreaMocksExpectations(); |
35 cros_mock_->InitMockCryptohomeLibrary(); | 34 cros_mock_->InitMockCryptohomeLibrary(); |
36 cros_mock_->InitMockScreenLockLibrary(); | |
37 mock_cryptohome_library_ = cros_mock_->mock_cryptohome_library(); | 35 mock_cryptohome_library_ = cros_mock_->mock_cryptohome_library(); |
38 mock_screen_lock_library_ = cros_mock_->mock_screen_lock_library(); | |
39 EXPECT_CALL(*mock_cryptohome_library_, IsMounted()) | 36 EXPECT_CALL(*mock_cryptohome_library_, IsMounted()) |
40 .WillRepeatedly(Return(true)); | 37 .WillRepeatedly(Return(true)); |
41 } | 38 } |
42 | 39 |
43 MockCryptohomeLibrary* mock_cryptohome_library_; | 40 MockCryptohomeLibrary* mock_cryptohome_library_; |
44 MockScreenLockLibrary* mock_screen_lock_library_; | 41 MockPowerManagerClient mock_power_manager_client_; |
45 | 42 |
46 private: | 43 private: |
47 DISALLOW_COPY_AND_ASSIGN(LoginTestBase); | 44 DISALLOW_COPY_AND_ASSIGN(LoginTestBase); |
48 }; | 45 }; |
49 | 46 |
50 class LoginUserTest : public LoginTestBase { | 47 class LoginUserTest : public LoginTestBase { |
51 protected: | 48 protected: |
52 virtual void SetUpInProcessBrowserTestFixture() { | 49 virtual void SetUpInProcessBrowserTestFixture() { |
53 LoginTestBase::SetUpInProcessBrowserTestFixture(); | 50 LoginTestBase::SetUpInProcessBrowserTestFixture(); |
54 EXPECT_CALL(*mock_screen_lock_library_, AddObserver(_)) | 51 EXPECT_CALL(mock_power_manager_client_, AddObserver(_)) |
55 .Times(AtLeast(1)) | 52 .Times(AtLeast(1)) |
56 .WillRepeatedly(Return()); | 53 .WillRepeatedly(Return()); |
57 EXPECT_CALL(*mock_screen_lock_library_, RemoveObserver(_)) | 54 EXPECT_CALL(mock_power_manager_client_, RemoveObserver(_)) |
58 .Times(AtLeast(1)) | 55 .Times(AtLeast(1)) |
59 .WillRepeatedly(Return()); | 56 .WillRepeatedly(Return()); |
60 } | 57 } |
61 | 58 |
62 virtual void SetUpCommandLine(CommandLine* command_line) { | 59 virtual void SetUpCommandLine(CommandLine* command_line) { |
63 command_line->AppendSwitchASCII(switches::kLoginUser, "TestUser@gmail.com"); | 60 command_line->AppendSwitchASCII(switches::kLoginUser, "TestUser@gmail.com"); |
64 command_line->AppendSwitchASCII(switches::kLoginProfile, "user"); | 61 command_line->AppendSwitchASCII(switches::kLoginProfile, "user"); |
65 command_line->AppendSwitch(switches::kNoFirstRun); | 62 command_line->AppendSwitch(switches::kNoFirstRun); |
66 } | 63 } |
67 }; | 64 }; |
(...skipping 18 matching lines...) Expand all Loading... |
86 // On initial launch, we should get the OTR default profile. | 83 // On initial launch, we should get the OTR default profile. |
87 IN_PROC_BROWSER_TEST_F(LoginProfileTest, UserNotPassed) { | 84 IN_PROC_BROWSER_TEST_F(LoginProfileTest, UserNotPassed) { |
88 Profile* profile = browser()->profile(); | 85 Profile* profile = browser()->profile(); |
89 EXPECT_EQ("Default", profile->GetPath().BaseName().value()); | 86 EXPECT_EQ("Default", profile->GetPath().BaseName().value()); |
90 EXPECT_TRUE(profile->IsOffTheRecord()); | 87 EXPECT_TRUE(profile->IsOffTheRecord()); |
91 // Ensure there's extension service for this profile. | 88 // Ensure there's extension service for this profile. |
92 EXPECT_TRUE(profile->GetExtensionService()); | 89 EXPECT_TRUE(profile->GetExtensionService()); |
93 } | 90 } |
94 | 91 |
95 } // namespace chromeos | 92 } // namespace chromeos |
OLD | NEW |