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

Side by Side Diff: chrome/browser/chromeos/cros/cros_mock.cc

Issue 14179007: Move cryptohome_library to src/chromeos (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 8 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/chromeos/cros/cros_mock.h" 5 #include "chrome/browser/chromeos/cros/cros_mock.h"
6 6
7 #include "base/memory/ref_counted.h" 7 #include "base/memory/ref_counted.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/time.h" 9 #include "base/time.h"
10 #include "chrome/browser/chromeos/cros/mock_cryptohome_library.h"
11 #include "chrome/browser/chromeos/cros/mock_network_library.h" 10 #include "chrome/browser/chromeos/cros/mock_network_library.h"
12 #include "chrome/browser/chromeos/login/screens/wizard_screen.h" 11 #include "chrome/browser/chromeos/login/screens/wizard_screen.h"
13 #include "chrome/browser/chromeos/login/wizard_controller.h" 12 #include "chrome/browser/chromeos/login/wizard_controller.h"
14 #include "chrome/test/base/in_process_browser_test.h" 13 #include "chrome/test/base/in_process_browser_test.h"
15 #include "chrome/test/base/ui_test_utils.h" 14 #include "chrome/test/base/ui_test_utils.h"
16 #include "testing/gmock/include/gmock/gmock.h" 15 #include "testing/gmock/include/gmock/gmock.h"
17 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
18 17
19 namespace chromeos { 18 namespace chromeos {
20 19
21 using ::testing::AnyNumber; 20 using ::testing::AnyNumber;
22 using ::testing::AtMost; 21 using ::testing::AtMost;
23 using ::testing::InSequence; 22 using ::testing::InSequence;
24 using ::testing::InvokeWithoutArgs; 23 using ::testing::InvokeWithoutArgs;
25 using ::testing::Return; 24 using ::testing::Return;
26 using ::testing::ReturnRef; 25 using ::testing::ReturnRef;
27 using ::testing::StrictMock; 26 using ::testing::StrictMock;
28 using ::testing::_; 27 using ::testing::_;
29 28
30 CrosMock::CrosMock() 29 CrosMock::CrosMock() : mock_network_library_(NULL) {
31 : mock_cryptohome_library_(NULL),
32 mock_network_library_(NULL) {
33 } 30 }
34 31
35 CrosMock::~CrosMock() { 32 CrosMock::~CrosMock() {
36 } 33 }
37 34
38 chromeos::CrosLibrary::TestApi* CrosMock::test_api() { 35 chromeos::CrosLibrary::TestApi* CrosMock::test_api() {
39 return chromeos::CrosLibrary::Get()->GetTestApi(); 36 return chromeos::CrosLibrary::Get()->GetTestApi();
40 } 37 }
41 38
42 void CrosMock::InitStatusAreaMocks() { 39 void CrosMock::InitStatusAreaMocks() {
43 InitMockNetworkLibrary(); 40 InitMockNetworkLibrary();
44 } 41 }
45 42
46 void CrosMock::InitMockCryptohomeLibrary() {
47 if (mock_cryptohome_library_)
48 return;
49 mock_cryptohome_library_ = new StrictMock<MockCryptohomeLibrary>();
50 test_api()->SetCryptohomeLibrary(mock_cryptohome_library_, true);
51 }
52
53 void CrosMock::InitMockNetworkLibrary() { 43 void CrosMock::InitMockNetworkLibrary() {
54 if (mock_network_library_) 44 if (mock_network_library_)
55 return; 45 return;
56 mock_network_library_ = new StrictMock<MockNetworkLibrary>(); 46 mock_network_library_ = new StrictMock<MockNetworkLibrary>();
57 test_api()->SetNetworkLibrary(mock_network_library_, true); 47 test_api()->SetNetworkLibrary(mock_network_library_, true);
58 } 48 }
59 49
60 // Initialization of mocks. 50 // Initialization of mocks.
61 MockCryptohomeLibrary* CrosMock::mock_cryptohome_library() {
62 return mock_cryptohome_library_;
63 }
64
65 MockNetworkLibrary* CrosMock::mock_network_library() { 51 MockNetworkLibrary* CrosMock::mock_network_library() {
66 return mock_network_library_; 52 return mock_network_library_;
67 } 53 }
68 54
69 void CrosMock::SetStatusAreaMocksExpectations() { 55 void CrosMock::SetStatusAreaMocksExpectations() {
70 SetNetworkLibraryStatusAreaExpectations(); 56 SetNetworkLibraryStatusAreaExpectations();
71 } 57 }
72 58
73 void CrosMock::SetNetworkLibraryStatusAreaExpectations() { 59 void CrosMock::SetNetworkLibraryStatusAreaExpectations() {
74 // We don't care how often these are called, just set their return values: 60 // We don't care how often these are called, just set their return values:
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 .WillRepeatedly((Return(false))) 183 .WillRepeatedly((Return(false)))
198 .RetiresOnSaturation(); 184 .RetiresOnSaturation();
199 EXPECT_CALL(*mock_network_library_, ethernet_connecting()) 185 EXPECT_CALL(*mock_network_library_, ethernet_connecting())
200 .Times(AnyNumber()) 186 .Times(AnyNumber())
201 .WillRepeatedly((Return(false))) 187 .WillRepeatedly((Return(false)))
202 .RetiresOnSaturation(); 188 .RetiresOnSaturation();
203 } 189 }
204 190
205 void CrosMock::TearDownMocks() { 191 void CrosMock::TearDownMocks() {
206 // Prevent bogus gMock leak check from firing. 192 // Prevent bogus gMock leak check from firing.
207 if (mock_cryptohome_library_)
208 test_api()->SetCryptohomeLibrary(NULL, false);
209 if (mock_network_library_) 193 if (mock_network_library_)
210 test_api()->SetNetworkLibrary(NULL, false); 194 test_api()->SetNetworkLibrary(NULL, false);
211 } 195 }
212 196
213 } // namespace chromeos 197 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698