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

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

Issue 5809001: Removed old login screen from source. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Reverted unnecessary changes Created 9 years, 11 months 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "app/l10n_util.h"
6 #include "base/message_loop.h"
7 #include "chrome/browser/chromeos/cros/cros_mock.h"
8 #include "chrome/browser/chromeos/cros/mock_cryptohome_library.h"
9 #include "chrome/browser/chromeos/cros/mock_login_library.h"
10 #include "chrome/browser/chromeos/cros/mock_network_library.h"
11 #include "chrome/browser/chromeos/login/existing_user_controller.h"
12 #include "chrome/browser/chromeos/login/login_performer.h"
13 #include "chrome/browser/chromeos/login/login_utils.h"
14 #include "chrome/browser/chromeos/login/mock_authenticator.h"
15 #include "chrome/browser/chromeos/login/wizard_controller.h"
16 #include "chrome/browser/chromeos/login/wizard_in_process_browser_test.h"
17 #include "grit/generated_resources.h"
18 #include "testing/gmock/include/gmock/gmock.h"
19 #include "testing/gtest/include/gtest/gtest.h"
20
21 namespace chromeos {
22
23 using ::testing::AnyNumber;
24 using ::testing::InvokeWithoutArgs;
25 using ::testing::Return;
26
27 const char kUsername[] = "test_user@gmail.com";
28 const char kPassword[] = "test_password";
29
30 class MockLoginPerformerDelegate : public LoginPerformer::Delegate {
31 public:
32 MockLoginPerformerDelegate(ExistingUserController* controller)
Dmitry Polukhin 2011/01/13 09:17:28 Please add explicit.
whywhat 2011/01/13 10:21:57 Done.
33 : controller_(controller) {
34 }
35
36 void OnLoginSuccess(const std::string&,
37 const std::string&,
38 const GaiaAuthConsumer::ClientLoginResult&,
39 bool) {
40 LoginPerformer* login_performer = controller_->login_performer_.release();
41 login_performer = NULL;
42 controller_->ActivateWizard(WizardController::kUserImageScreenName);
43 delete WizardController::default_controller();
44 }
45
46 MOCK_METHOD1(OnLoginFailure, void(const LoginFailure&));
47 MOCK_METHOD1(WhiteListCheckFailed, void(const std::string&));
48
49 private:
50 ExistingUserController* controller_;
51
52 DISALLOW_COPY_AND_ASSIGN(MockLoginPerformerDelegate);
53 };
54
55 class ExistingUserControllerTest : public WizardInProcessBrowserTest {
56 protected:
57 ExistingUserControllerTest()
58 : chromeos::WizardInProcessBrowserTest(
59 WizardController::kLoginScreenName),
60 mock_cryptohome_library_(NULL),
61 mock_login_library_(NULL),
62 mock_network_library_(NULL) {
63 }
64
65 virtual ~ExistingUserControllerTest() {}
Dmitry Polukhin 2011/01/13 09:17:28 There is no point in such destructor - it will be
whywhat 2011/01/13 10:21:57 Done.
66
67 ExistingUserController* existing_user_controller() {
68 return ExistingUserController::current_controller();
69 }
70
71 MockCryptohomeLibrary* mock_cryptohome_library_;
Dmitry Polukhin 2011/01/13 09:17:28 Could you please don't mix data-members and functi
whywhat 2011/01/13 10:21:57 Done.
72 MockLoginLibrary* mock_login_library_;
73 MockNetworkLibrary* mock_network_library_;
74
75 virtual void SetUpInProcessBrowserTestFixture() {
76 WizardInProcessBrowserTest::SetUpInProcessBrowserTestFixture();
77 cros_mock_->InitStatusAreaMocks();
78 cros_mock_->SetStatusAreaMocksExpectations();
79
80 mock_network_library_ = cros_mock_->mock_network_library();
81
82 mock_login_library_ = new MockLoginLibrary();
83 EXPECT_CALL(*mock_login_library_, EmitLoginPromptReady())
84 .Times(1);
85 EXPECT_CALL(*mock_login_library_, RetrieveProperty(_, _, _))
86 .Times(AnyNumber())
87 .WillRepeatedly((Return(true)));
88 cros_mock_->test_api()->SetLoginLibrary(mock_login_library_, true);
89
90 cros_mock_->InitMockCryptohomeLibrary();
91 mock_cryptohome_library_ = cros_mock_->mock_cryptohome_library();
92 EXPECT_CALL(*mock_cryptohome_library_, IsMounted())
93 .Times(AnyNumber())
94 .WillRepeatedly((Return(true)));
95 LoginUtils::Set(new MockLoginUtils(kUsername, kPassword));
96 }
97
98 virtual void TearDownInProcessBrowserTestFixture() {
99 WizardInProcessBrowserTest::TearDownInProcessBrowserTestFixture();
100 cros_mock_->test_api()->SetLoginLibrary(NULL, false);
101 }
102
103 private:
104 DISALLOW_COPY_AND_ASSIGN(ExistingUserControllerTest);
105 };
106
107 IN_PROC_BROWSER_TEST_F(ExistingUserControllerTest, NewUserLogin) {
108 MockLoginPerformerDelegate* mock_delegate =
109 new MockLoginPerformerDelegate(existing_user_controller());
110 existing_user_controller()->set_login_performer_delegate(mock_delegate);
111
112 existing_user_controller()->LoginNewUser(kUsername, kPassword);
113 }
114
115 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698