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

Side by Side Diff: chromeos/cryptohome/mock_homedir_methods.cc

Issue 2540683002: Don't defer quitting in ExecuteScript and other helpers that use DOMMessageQueue. (Closed)
Patch Set: Change FIXME to TODO. Created 4 years 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chromeos/cryptohome/mock_homedir_methods.h" 5 #include "chromeos/cryptohome/mock_homedir_methods.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "chromeos/cryptohome/cryptohome_parameters.h" 9 #include "chromeos/cryptohome/cryptohome_parameters.h"
10 #include "chromeos/cryptohome/mock_async_method_caller.h" 10 #include "chromeos/cryptohome/mock_async_method_caller.h"
11 11
12 using ::testing::Invoke; 12 using ::testing::Invoke;
13 using ::testing::WithArgs; 13 using ::testing::WithArgs;
14 using ::testing::_; 14 using ::testing::_;
15 15
16 namespace cryptohome { 16 namespace cryptohome {
17 17
18 MockHomedirMethods::MockHomedirMethods() 18 MockHomedirMethods::MockHomedirMethods()
19 : success_(false), return_code_(cryptohome::MOUNT_ERROR_NONE) {} 19 : success_(false), return_code_(cryptohome::MOUNT_ERROR_NONE) {}
achuithb 2016/11/30 22:39:52 Please move this initialization to the header sinc
Alexander Semashko 2016/12/01 12:24:59 Done.
20 20
21 MockHomedirMethods::~MockHomedirMethods() {} 21 MockHomedirMethods::~MockHomedirMethods() {}
22 22
23 void MockHomedirMethods::SetUp(bool success, MountError return_code) { 23 void MockHomedirMethods::SetUp(bool success, MountError return_code) {
24 success_ = success; 24 success_ = success;
25 return_code_ = return_code; 25 return_code_ = return_code;
26 ON_CALL(*this, GetKeyDataEx(_, _, _)).WillByDefault( 26 ON_CALL(*this, GetKeyDataEx(_, _, _)).WillByDefault(
27 WithArgs<2>(Invoke(this, &MockHomedirMethods::DoGetDataCallback))); 27 WithArgs<2>(Invoke(this, &MockHomedirMethods::DoGetDataCallback)));
28 ON_CALL(*this, CheckKeyEx(_, _, _)).WillByDefault( 28 ON_CALL(*this, CheckKeyEx(_, _, _)).WillByDefault(
29 WithArgs<2>(Invoke(this, &MockHomedirMethods::DoCallback))); 29 WithArgs<2>(Invoke(this, &MockHomedirMethods::DoCallback)));
30 ON_CALL(*this, MountEx(_, _, _, _)).WillByDefault( 30 ON_CALL(*this, MountEx(_, _, _, _)).WillByDefault(
31 WithArgs<3>(Invoke(this, &MockHomedirMethods::DoMountCallback))); 31 WithArgs<3>(Invoke(this, &MockHomedirMethods::DoMountCallback)));
32 ON_CALL(*this, AddKeyEx(_, _, _, _, _)).WillByDefault( 32 ON_CALL(*this, AddKeyEx(_, _, _, _, _))
33 WithArgs<4>(Invoke(this, &MockHomedirMethods::DoCallback))); 33 .WillByDefault(
34 WithArgs<4>(Invoke(this, &MockHomedirMethods::DoAddKeyCallback)));
34 ON_CALL(*this, UpdateKeyEx(_, _, _, _, _)).WillByDefault( 35 ON_CALL(*this, UpdateKeyEx(_, _, _, _, _)).WillByDefault(
35 WithArgs<4>(Invoke(this, &MockHomedirMethods::DoCallback))); 36 WithArgs<4>(Invoke(this, &MockHomedirMethods::DoCallback)));
36 ON_CALL(*this, RemoveKeyEx(_, _, _, _)).WillByDefault( 37 ON_CALL(*this, RemoveKeyEx(_, _, _, _)).WillByDefault(
37 WithArgs<3>(Invoke(this, &MockHomedirMethods::DoCallback))); 38 WithArgs<3>(Invoke(this, &MockHomedirMethods::DoCallback)));
38 } 39 }
39 40
40 void MockHomedirMethods::DoCallback(const Callback& callback) { 41 void MockHomedirMethods::DoCallback(const Callback& callback) {
41 callback.Run(success_, return_code_); 42 callback.Run(success_, return_code_);
42 } 43 }
43 44
44 void MockHomedirMethods::DoGetDataCallback(const GetKeyDataCallback& callback) { 45 void MockHomedirMethods::DoGetDataCallback(const GetKeyDataCallback& callback) {
45 callback.Run(success_, return_code_, std::vector<KeyDefinition>()); 46 callback.Run(success_, return_code_, std::vector<KeyDefinition>());
46 } 47 }
47 48
48 void MockHomedirMethods::DoMountCallback(const MountCallback& callback) { 49 void MockHomedirMethods::DoMountCallback(const MountCallback& callback) {
49 callback.Run( 50 callback.Run(
50 success_, return_code_, MockAsyncMethodCaller::kFakeSanitizedUsername); 51 success_, return_code_, MockAsyncMethodCaller::kFakeSanitizedUsername);
52 if (!on_mount_called_.is_null())
53 on_mount_called_.Run();
54 }
55
56 void MockHomedirMethods::DoAddKeyCallback(const Callback& callback) {
57 callback.Run(success_, return_code_);
58 if (!on_add_key_called_.is_null())
59 on_add_key_called_.Run();
51 } 60 }
52 61
53 } // namespace cryptohome 62 } // namespace cryptohome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698