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