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

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

Issue 2314853004: Remove calls to deprecated MessageLoop methods in chromeos. (Closed)
Patch Set: Created 4 years, 3 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) 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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/run_loop.h"
8 #include "base/values.h" 9 #include "base/values.h"
9 #include "chromeos/dbus/shill_client_unittest_base.h" 10 #include "chromeos/dbus/shill_client_unittest_base.h"
10 #include "chromeos/dbus/shill_ipconfig_client.h" 11 #include "chromeos/dbus/shill_ipconfig_client.h"
11 #include "dbus/message.h" 12 #include "dbus/message.h"
12 #include "dbus/values_util.h" 13 #include "dbus/values_util.h"
13 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
14 #include "third_party/cros_system_api/dbus/service_constants.h" 15 #include "third_party/cros_system_api/dbus/service_constants.h"
15 16
16 using testing::_; 17 using testing::_;
17 using testing::ByRef; 18 using testing::ByRef;
(...skipping 13 matching lines...) Expand all
31 shill::kFlimflamIPConfigInterface, 32 shill::kFlimflamIPConfigInterface,
32 dbus::ObjectPath(kExampleIPConfigPath)) { 33 dbus::ObjectPath(kExampleIPConfigPath)) {
33 } 34 }
34 35
35 void SetUp() override { 36 void SetUp() override {
36 ShillClientUnittestBase::SetUp(); 37 ShillClientUnittestBase::SetUp();
37 // Create a client with the mock bus. 38 // Create a client with the mock bus.
38 client_.reset(ShillIPConfigClient::Create()); 39 client_.reset(ShillIPConfigClient::Create());
39 client_->Init(mock_bus_.get()); 40 client_->Init(mock_bus_.get());
40 // Run the message loop to run the signal connection result callback. 41 // Run the message loop to run the signal connection result callback.
41 message_loop_.RunUntilIdle(); 42 base::RunLoop().RunUntilIdle();
42 } 43 }
43 44
44 void TearDown() override { ShillClientUnittestBase::TearDown(); } 45 void TearDown() override { ShillClientUnittestBase::TearDown(); }
45 46
46 protected: 47 protected:
47 std::unique_ptr<ShillIPConfigClient> client_; 48 std::unique_ptr<ShillIPConfigClient> client_;
48 }; 49 };
49 50
50 TEST_F(ShillIPConfigClientTest, PropertyChanged) { 51 TEST_F(ShillIPConfigClientTest, PropertyChanged) {
51 // Create a signal. 52 // Create a signal.
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 new base::FundamentalValue(kMtu)); 111 new base::FundamentalValue(kMtu));
111 112
112 // Set expectations. 113 // Set expectations.
113 PrepareForMethodCall(shill::kGetPropertiesFunction, 114 PrepareForMethodCall(shill::kGetPropertiesFunction,
114 base::Bind(&ExpectNoArgument), 115 base::Bind(&ExpectNoArgument),
115 response.get()); 116 response.get());
116 // Call method. 117 // Call method.
117 client_->GetProperties(dbus::ObjectPath(kExampleIPConfigPath), 118 client_->GetProperties(dbus::ObjectPath(kExampleIPConfigPath),
118 base::Bind(&ExpectDictionaryValueResult, &value)); 119 base::Bind(&ExpectDictionaryValueResult, &value));
119 // Run the message loop. 120 // Run the message loop.
120 message_loop_.RunUntilIdle(); 121 base::RunLoop().RunUntilIdle();
121 } 122 }
122 123
123 TEST_F(ShillIPConfigClientTest, SetProperty) { 124 TEST_F(ShillIPConfigClientTest, SetProperty) {
124 const char kAddress[] = "address"; 125 const char kAddress[] = "address";
125 126
126 // Create response. 127 // Create response.
127 std::unique_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); 128 std::unique_ptr<dbus::Response> response(dbus::Response::CreateEmpty());
128 129
129 // Set expectations. 130 // Set expectations.
130 base::StringValue value(kAddress); 131 base::StringValue value(kAddress);
131 PrepareForMethodCall(shill::kSetPropertyFunction, 132 PrepareForMethodCall(shill::kSetPropertyFunction,
132 base::Bind(&ExpectStringAndValueArguments, 133 base::Bind(&ExpectStringAndValueArguments,
133 shill::kAddressProperty, 134 shill::kAddressProperty,
134 &value), 135 &value),
135 response.get()); 136 response.get());
136 // Call method. 137 // Call method.
137 client_->SetProperty(dbus::ObjectPath(kExampleIPConfigPath), 138 client_->SetProperty(dbus::ObjectPath(kExampleIPConfigPath),
138 shill::kAddressProperty, 139 shill::kAddressProperty,
139 value, 140 value,
140 base::Bind(&ExpectNoResultValue)); 141 base::Bind(&ExpectNoResultValue));
141 // Run the message loop. 142 // Run the message loop.
142 message_loop_.RunUntilIdle(); 143 base::RunLoop().RunUntilIdle();
143 } 144 }
144 145
145 TEST_F(ShillIPConfigClientTest, ClearProperty) { 146 TEST_F(ShillIPConfigClientTest, ClearProperty) {
146 // Create response. 147 // Create response.
147 std::unique_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); 148 std::unique_ptr<dbus::Response> response(dbus::Response::CreateEmpty());
148 149
149 // Set expectations. 150 // Set expectations.
150 PrepareForMethodCall(shill::kClearPropertyFunction, 151 PrepareForMethodCall(shill::kClearPropertyFunction,
151 base::Bind(&ExpectStringArgument, 152 base::Bind(&ExpectStringArgument,
152 shill::kAddressProperty), 153 shill::kAddressProperty),
153 response.get()); 154 response.get());
154 // Call method. 155 // Call method.
155 client_->ClearProperty(dbus::ObjectPath(kExampleIPConfigPath), 156 client_->ClearProperty(dbus::ObjectPath(kExampleIPConfigPath),
156 shill::kAddressProperty, 157 shill::kAddressProperty,
157 base::Bind(&ExpectNoResultValue)); 158 base::Bind(&ExpectNoResultValue));
158 // Run the message loop. 159 // Run the message loop.
159 message_loop_.RunUntilIdle(); 160 base::RunLoop().RunUntilIdle();
160 } 161 }
161 162
162 TEST_F(ShillIPConfigClientTest, Remove) { 163 TEST_F(ShillIPConfigClientTest, Remove) {
163 // Create response. 164 // Create response.
164 std::unique_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); 165 std::unique_ptr<dbus::Response> response(dbus::Response::CreateEmpty());
165 166
166 // Set expectations. 167 // Set expectations.
167 PrepareForMethodCall(shill::kRemoveConfigFunction, 168 PrepareForMethodCall(shill::kRemoveConfigFunction,
168 base::Bind(&ExpectNoArgument), 169 base::Bind(&ExpectNoArgument),
169 response.get()); 170 response.get());
170 // Call method. 171 // Call method.
171 client_->Remove(dbus::ObjectPath(kExampleIPConfigPath), 172 client_->Remove(dbus::ObjectPath(kExampleIPConfigPath),
172 base::Bind(&ExpectNoResultValue)); 173 base::Bind(&ExpectNoResultValue));
173 174
174 // Run the message loop. 175 // Run the message loop.
175 message_loop_.RunUntilIdle(); 176 base::RunLoop().RunUntilIdle();
176 } 177 }
177 178
178 } // namespace chromeos 179 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698