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

Side by Side Diff: chromeos/dbus/blocking_method_caller_unittest.cc

Issue 2890433002: Revert "Abandon user sign in when policy is retrieved before session started." (Closed)
Patch Set: Created 3 years, 7 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
« no previous file with comments | « chromeos/dbus/blocking_method_caller.cc ('k') | chromeos/dbus/fake_session_manager_client.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "chromeos/dbus/blocking_method_caller.h" 5 #include "chromeos/dbus/blocking_method_caller.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 mock_bus_ = new dbus::MockBus(options); 53 mock_bus_ = new dbus::MockBus(options);
54 54
55 // Create a mock proxy. 55 // Create a mock proxy.
56 mock_proxy_ = new dbus::MockObjectProxy( 56 mock_proxy_ = new dbus::MockObjectProxy(
57 mock_bus_.get(), 57 mock_bus_.get(),
58 "org.chromium.TestService", 58 "org.chromium.TestService",
59 dbus::ObjectPath("/org/chromium/TestObject")); 59 dbus::ObjectPath("/org/chromium/TestObject"));
60 60
61 // Set an expectation so mock_proxy's CallMethodAndBlock() will use 61 // Set an expectation so mock_proxy's CallMethodAndBlock() will use
62 // CreateMockProxyResponse() to return responses. 62 // CreateMockProxyResponse() to return responses.
63 EXPECT_CALL(*mock_proxy_.get(), 63 EXPECT_CALL(*mock_proxy_.get(), MockCallMethodAndBlock(_, _))
64 MockCallMethodAndBlockWithErrorDetails(_, _, _))
65 .WillRepeatedly( 64 .WillRepeatedly(
66 Invoke(this, &BlockingMethodCallerTest::CreateMockProxyResponse)); 65 Invoke(this, &BlockingMethodCallerTest::CreateMockProxyResponse));
67 66
68 // Set an expectation so mock_bus's GetObjectProxy() for the given 67 // Set an expectation so mock_bus's GetObjectProxy() for the given
69 // service name and the object path will return mock_proxy_. 68 // service name and the object path will return mock_proxy_.
70 EXPECT_CALL(*mock_bus_.get(), 69 EXPECT_CALL(*mock_bus_.get(),
71 GetObjectProxy("org.chromium.TestService", 70 GetObjectProxy("org.chromium.TestService",
72 dbus::ObjectPath("/org/chromium/TestObject"))) 71 dbus::ObjectPath("/org/chromium/TestObject")))
73 .WillOnce(Return(mock_proxy_.get())); 72 .WillOnce(Return(mock_proxy_.get()));
74 73
75 // Set an expectation so mock_bus's GetDBusTaskRunner will return the fake 74 // Set an expectation so mock_bus's GetDBusTaskRunner will return the fake
76 // task runner. 75 // task runner.
77 EXPECT_CALL(*mock_bus_.get(), GetDBusTaskRunner()) 76 EXPECT_CALL(*mock_bus_.get(), GetDBusTaskRunner())
78 .WillRepeatedly(Return(task_runner_.get())); 77 .WillRepeatedly(Return(task_runner_.get()));
79 78
80 // ShutdownAndBlock() will be called in TearDown(). 79 // ShutdownAndBlock() will be called in TearDown().
81 EXPECT_CALL(*mock_bus_.get(), ShutdownAndBlock()).WillOnce(Return()); 80 EXPECT_CALL(*mock_bus_.get(), ShutdownAndBlock()).WillOnce(Return());
82 } 81 }
83 82
84 void TearDown() override { mock_bus_->ShutdownAndBlock(); } 83 void TearDown() override { mock_bus_->ShutdownAndBlock(); }
85 84
86 protected: 85 protected:
87 scoped_refptr<FakeTaskRunner> task_runner_; 86 scoped_refptr<FakeTaskRunner> task_runner_;
88 scoped_refptr<dbus::MockBus> mock_bus_; 87 scoped_refptr<dbus::MockBus> mock_bus_;
89 scoped_refptr<dbus::MockObjectProxy> mock_proxy_; 88 scoped_refptr<dbus::MockObjectProxy> mock_proxy_;
90 89
91 private: 90 private:
92 // Returns a response for the given method call. Used to implement 91 // Returns a response for the given method call. Used to implement
93 // CallMethodAndBlock() for |mock_proxy_|. 92 // CallMethodAndBlock() for |mock_proxy_|.
94 dbus::Response* CreateMockProxyResponse(dbus::MethodCall* method_call, 93 dbus::Response* CreateMockProxyResponse(dbus::MethodCall* method_call,
95 int timeout_ms, 94 int timeout_ms) {
96 dbus::ScopedDBusError* error) {
97 if (method_call->GetInterface() == "org.chromium.TestInterface" && 95 if (method_call->GetInterface() == "org.chromium.TestInterface" &&
98 method_call->GetMember() == "Echo") { 96 method_call->GetMember() == "Echo") {
99 dbus::MessageReader reader(method_call); 97 dbus::MessageReader reader(method_call);
100 std::string text_message; 98 std::string text_message;
101 if (reader.PopString(&text_message)) { 99 if (reader.PopString(&text_message)) {
102 std::unique_ptr<dbus::Response> response = 100 std::unique_ptr<dbus::Response> response =
103 dbus::Response::CreateEmpty(); 101 dbus::Response::CreateEmpty();
104 dbus::MessageWriter writer(response.get()); 102 dbus::MessageWriter writer(response.get());
105 writer.AppendString(text_message); 103 writer.AppendString(text_message);
106 return response.release(); 104 return response.release();
(...skipping 25 matching lines...) Expand all
132 // Check the response. 130 // Check the response.
133 ASSERT_TRUE(response.get()); 131 ASSERT_TRUE(response.get());
134 dbus::MessageReader reader(response.get()); 132 dbus::MessageReader reader(response.get());
135 std::string text_message; 133 std::string text_message;
136 ASSERT_TRUE(reader.PopString(&text_message)); 134 ASSERT_TRUE(reader.PopString(&text_message));
137 // The text message should be echo'ed back. 135 // The text message should be echo'ed back.
138 EXPECT_EQ(kHello, text_message); 136 EXPECT_EQ(kHello, text_message);
139 } 137 }
140 138
141 } // namespace chromeos 139 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/dbus/blocking_method_caller.cc ('k') | chromeos/dbus/fake_session_manager_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698