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

Side by Side Diff: chrome/browser/chromeos/login/mock_login_status_consumer.h

Issue 3442009: [Chrome OS] Attempt offline and online login simultaneously (Closed)
Patch Set: Fix crash on data recover Created 10 years, 2 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_MOCK_LOGIN_STATUS_CONSUMER_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_MOCK_LOGIN_STATUS_CONSUMER_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_MOCK_LOGIN_STATUS_CONSUMER_H_ 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_MOCK_LOGIN_STATUS_CONSUMER_H_
7 #pragma once 7 #pragma once
8 8
9 #include "chrome/browser/chromeos/login/login_status_consumer.h" 9 #include "chrome/browser/chromeos/login/login_status_consumer.h"
10 #include "chrome/common/net/gaia/gaia_auth_consumer.h" 10 #include "chrome/common/net/gaia/gaia_auth_consumer.h"
11 #include "testing/gmock/include/gmock/gmock.h" 11 #include "testing/gmock/include/gmock/gmock.h"
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 13
14 namespace chromeos { 14 namespace chromeos {
15 15
16 class MockConsumer : public LoginStatusConsumer { 16 class MockConsumer : public LoginStatusConsumer {
17 public: 17 public:
18 MockConsumer() {} 18 MockConsumer() {}
19 ~MockConsumer() {} 19 ~MockConsumer() {}
20 MOCK_METHOD1(OnLoginFailure, void(const LoginFailure& error)); 20 MOCK_METHOD1(OnLoginFailure, void(const LoginFailure& error));
21 MOCK_METHOD3(OnLoginSuccess, void( 21 MOCK_METHOD3(OnLoginSuccess, void(
22 const std::string& username, 22 const std::string& username,
23 const GaiaAuthConsumer::ClientLoginResult& result, 23 const GaiaAuthConsumer::ClientLoginResult& result,
24 bool pending_requests)); 24 bool pending_requests));
25 MOCK_METHOD0(OnOffTheRecordLoginSuccess, void(void)); 25 MOCK_METHOD0(OnOffTheRecordLoginSuccess, void(void));
26 MOCK_METHOD1(OnPasswordChangeDetected, 26 MOCK_METHOD1(OnPasswordChangeDetected,
27 void(const GaiaAuthConsumer::ClientLoginResult& result)); 27 void(const GaiaAuthConsumer::ClientLoginResult& result));
28
29 // The following functions can be used in gmock Invoke() clauses.
30
31 // Compatible with LoginStatusConsumer::OnOffTheRecordLoginSuccess()
32 static void OnGuestSuccessQuit() {
33 MessageLoop::current()->Quit();
34 }
35
36 static void OnGuestSuccessQuitAndFail() {
37 ADD_FAILURE() << "Guest Login should have failed!";
38 MessageLoop::current()->Quit();
39 }
40
41 // Compatible with LoginStatusConsumer::OnLoginSuccess()
42 static void OnSuccessQuit(
43 const std::string& username,
44 const GaiaAuthConsumer::ClientLoginResult& credentials,
45 bool pending_requests) {
46 MessageLoop::current()->Quit();
47 }
48
49 static void OnSuccessQuitAndFail(
50 const std::string& username,
51 const GaiaAuthConsumer::ClientLoginResult& credentials,
52 bool pending_requests) {
53 ADD_FAILURE() << "Login should NOT have succeeded!";
54 MessageLoop::current()->Quit();
55 }
56
57 // Compatible with LoginStatusConsumer::OnLoginFailure()
58 static void OnFailQuit(const LoginFailure& error) {
59 MessageLoop::current()->Quit();
60 }
61
62 static void OnFailQuitAndFail(const LoginFailure& error) {
63 ADD_FAILURE() << "Login should not have failed!";
64 MessageLoop::current()->Quit();
65 }
66
67 // Compatible with LoginStatusConsumer::OnPasswordChangeDetected()
68 static void OnMigrateQuit(
69 const GaiaAuthConsumer::ClientLoginResult& credentials) {
70 MessageLoop::current()->Quit();
71 }
72
73 static void OnMigrateQuitAndFail(
74 const GaiaAuthConsumer::ClientLoginResult& credentials) {
75 ADD_FAILURE() << "Should not have detected a PW change!";
76 MessageLoop::current()->Quit();
77 }
28 }; 78 };
29 79
30 } // namespace chromeos 80 } // namespace chromeos
31 81
32 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_MOCK_LOGIN_STATUS_CONSUMER_H_ 82 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_MOCK_LOGIN_STATUS_CONSUMER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698