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

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: fixed comments 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 explicit MockLoginPerformerDelegate(ExistingUserController* controller)
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 ExistingUserController* existing_user_controller() {
66 return ExistingUserController::current_controller();
67 }
68
69 virtual void SetUpInProcessBrowserTestFixture() {
70 WizardInProcessBrowserTest::SetUpInProcessBrowserTestFixture();
71 cros_mock_->InitStatusAreaMocks();
72 cros_mock_->SetStatusAreaMocksExpectations();
73
74 mock_network_library_ = cros_mock_->mock_network_library();
75
76 mock_login_library_ = new MockLoginLibrary();
77 EXPECT_CALL(*mock_login_library_, EmitLoginPromptReady())
78 .Times(1);
79 EXPECT_CALL(*mock_login_library_, RetrieveProperty(_, _, _))
80 .Times(AnyNumber())
81 .WillRepeatedly((Return(true)));
82 cros_mock_->test_api()->SetLoginLibrary(mock_login_library_, true);
83
84 cros_mock_->InitMockCryptohomeLibrary();
85 mock_cryptohome_library_ = cros_mock_->mock_cryptohome_library();
86 EXPECT_CALL(*mock_cryptohome_library_, IsMounted())
87 .Times(AnyNumber())
88 .WillRepeatedly((Return(true)));
89 LoginUtils::Set(new MockLoginUtils(kUsername, kPassword));
90 }
91
92 virtual void TearDownInProcessBrowserTestFixture() {
93 WizardInProcessBrowserTest::TearDownInProcessBrowserTestFixture();
94 cros_mock_->test_api()->SetLoginLibrary(NULL, false);
95 }
96
97 MockCryptohomeLibrary* mock_cryptohome_library_;
98 MockLoginLibrary* mock_login_library_;
99 MockNetworkLibrary* mock_network_library_;
100
101 private:
102 DISALLOW_COPY_AND_ASSIGN(ExistingUserControllerTest);
103 };
104
105 IN_PROC_BROWSER_TEST_F(ExistingUserControllerTest, NewUserLogin) {
106 MockLoginPerformerDelegate* mock_delegate =
107 new MockLoginPerformerDelegate(existing_user_controller());
108 existing_user_controller()->set_login_performer_delegate(mock_delegate);
109
110 existing_user_controller()->LoginNewUser(kUsername, kPassword);
111 }
112
113 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/existing_user_controller.cc ('k') | chrome/browser/chromeos/login/login_screen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698