Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(29)

Side by Side Diff: chrome/browser/chromeos/login/login_browsertest.cc

Issue 8639008: chromeos: Fix LoginUserTest.UserPassed and LoginProfileTest.UserNotPassed. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_power_library.h" 11 #include "chrome/browser/chromeos/cros/mock_power_library.h"
12 #include "chrome/browser/chromeos/cros/mock_screen_lock_library.h" 12 #include "chrome/browser/chromeos/cros/mock_screen_lock_library.h"
13 #include "chrome/browser/profiles/profile_manager.h" 13 #include "chrome/browser/profiles/profile_manager.h"
14 #include "chrome/browser/ui/browser.h" 14 #include "chrome/browser/ui/browser.h"
15 #include "chrome/common/chrome_switches.h" 15 #include "chrome/common/chrome_switches.h"
16 #include "chrome/test/base/in_process_browser_test.h" 16 #include "chrome/test/base/in_process_browser_test.h"
17 #include "chrome/test/base/ui_test_utils.h" 17 #include "chrome/test/base/ui_test_utils.h"
18 #include "testing/gmock/include/gmock/gmock.h" 18 #include "testing/gmock/include/gmock/gmock.h"
19 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
20 20
21 namespace chromeos { 21 namespace chromeos {
22 using ::testing::_; 22 using ::testing::_;
23 using ::testing::AtLeast;
23 using ::testing::Return; 24 using ::testing::Return;
24 25
25 class LoginTestBase : public CrosInProcessBrowserTest { 26 class LoginTestBase : public CrosInProcessBrowserTest {
26 public: 27 public:
27 LoginTestBase() : mock_cryptohome_library_(NULL), 28 LoginTestBase() : mock_cryptohome_library_(NULL),
28 mock_screen_lock_library_(NULL) { 29 mock_screen_lock_library_(NULL) {
29 } 30 }
30 31
31 protected: 32 protected:
32 virtual void SetUpInProcessBrowserTestFixture() { 33 virtual void SetUpInProcessBrowserTestFixture() {
(...skipping 14 matching lines...) Expand all
47 DISALLOW_COPY_AND_ASSIGN(LoginTestBase); 48 DISALLOW_COPY_AND_ASSIGN(LoginTestBase);
48 }; 49 };
49 50
50 class LoginUserTest : public LoginTestBase { 51 class LoginUserTest : public LoginTestBase {
51 protected: 52 protected:
52 virtual void SetUpInProcessBrowserTestFixture() { 53 virtual void SetUpInProcessBrowserTestFixture() {
53 LoginTestBase::SetUpInProcessBrowserTestFixture(); 54 LoginTestBase::SetUpInProcessBrowserTestFixture();
54 // TODO(nkostylev): Remove this once Aura build includes ScreenLocker. 55 // TODO(nkostylev): Remove this once Aura build includes ScreenLocker.
55 #if !defined(USE_AURA) 56 #if !defined(USE_AURA)
56 EXPECT_CALL(*mock_screen_lock_library_, AddObserver(_)) 57 EXPECT_CALL(*mock_screen_lock_library_, AddObserver(_))
57 .WillOnce(Return()); 58 .Times(AtLeast(1))
59 .WillRepeatedly(Return());
60 EXPECT_CALL(*mock_screen_lock_library_, RemoveObserver(_))
61 .Times(AtLeast(1))
62 .WillRepeatedly(Return());
58 #endif 63 #endif
59 } 64 }
60 65
61 virtual void SetUpCommandLine(CommandLine* command_line) { 66 virtual void SetUpCommandLine(CommandLine* command_line) {
62 command_line->AppendSwitchASCII(switches::kLoginUser, "TestUser@gmail.com"); 67 command_line->AppendSwitchASCII(switches::kLoginUser, "TestUser@gmail.com");
63 command_line->AppendSwitchASCII(switches::kLoginProfile, "user"); 68 command_line->AppendSwitchASCII(switches::kLoginProfile, "user");
64 command_line->AppendSwitch(switches::kNoFirstRun); 69 command_line->AppendSwitch(switches::kNoFirstRun);
65 } 70 }
66 }; 71 };
67 72
68 class LoginProfileTest : public LoginTestBase { 73 class LoginProfileTest : public LoginUserTest {
69 protected: 74 protected:
70 virtual void SetUpCommandLine(CommandLine* command_line) { 75 virtual void SetUpCommandLine(CommandLine* command_line) {
71 command_line->AppendSwitchASCII(switches::kLoginProfile, "user"); 76 command_line->AppendSwitchASCII(switches::kLoginProfile, "user");
72 command_line->AppendSwitch(switches::kNoFirstRun); 77 command_line->AppendSwitch(switches::kNoFirstRun);
73 } 78 }
74 }; 79 };
75 80
76 // After a chrome crash, the session manager will restart chrome with 81 // After a chrome crash, the session manager will restart chrome with
77 // the -login-user flag indicating that the user is already logged in. 82 // the -login-user flag indicating that the user is already logged in.
78 // This profile should NOT be an OTR profile. 83 // This profile should NOT be an OTR profile.
79 IN_PROC_BROWSER_TEST_F(LoginUserTest, UserPassed) { 84 IN_PROC_BROWSER_TEST_F(LoginUserTest, UserPassed) {
80 Profile* profile = browser()->profile(); 85 Profile* profile = browser()->profile();
81 EXPECT_EQ("user", profile->GetPath().BaseName().value()); 86 EXPECT_EQ("user", profile->GetPath().BaseName().value());
82 EXPECT_FALSE(profile->IsOffTheRecord()); 87 EXPECT_FALSE(profile->IsOffTheRecord());
83 } 88 }
84 89
85 // On initial launch, we should get the OTR default profile. 90 // On initial launch, we should get the OTR default profile.
86 IN_PROC_BROWSER_TEST_F(LoginProfileTest, UserNotPassed) { 91 IN_PROC_BROWSER_TEST_F(LoginProfileTest, UserNotPassed) {
87 Profile* profile = browser()->profile(); 92 Profile* profile = browser()->profile();
88 EXPECT_EQ("Default", profile->GetPath().BaseName().value()); 93 EXPECT_EQ("Default", profile->GetPath().BaseName().value());
89 EXPECT_TRUE(profile->IsOffTheRecord()); 94 EXPECT_TRUE(profile->IsOffTheRecord());
90 // Ensure there's extension service for this profile. 95 // Ensure there's extension service for this profile.
91 EXPECT_TRUE(profile->GetExtensionService()); 96 EXPECT_TRUE(profile->GetExtensionService());
92 } 97 }
93 98
94 } // namespace chromeos 99 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698