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

Side by Side Diff: chromeos/dbus/shill_profile_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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/run_loop.h"
6 #include "base/values.h" 7 #include "base/values.h"
7 #include "chromeos/dbus/shill_client_unittest_base.h" 8 #include "chromeos/dbus/shill_client_unittest_base.h"
8 #include "chromeos/dbus/shill_profile_client.h" 9 #include "chromeos/dbus/shill_profile_client.h"
9 #include "dbus/message.h" 10 #include "dbus/message.h"
10 #include "dbus/object_path.h" 11 #include "dbus/object_path.h"
11 #include "dbus/values_util.h" 12 #include "dbus/values_util.h"
12 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
13 #include "third_party/cros_system_api/dbus/service_constants.h" 14 #include "third_party/cros_system_api/dbus/service_constants.h"
14 15
15 using testing::_; 16 using testing::_;
(...skipping 21 matching lines...) Expand all
37 : ShillClientUnittestBase(shill::kFlimflamProfileInterface, 38 : ShillClientUnittestBase(shill::kFlimflamProfileInterface,
38 dbus::ObjectPath(kDefaultProfilePath)) { 39 dbus::ObjectPath(kDefaultProfilePath)) {
39 } 40 }
40 41
41 void SetUp() override { 42 void SetUp() override {
42 ShillClientUnittestBase::SetUp(); 43 ShillClientUnittestBase::SetUp();
43 // Create a client with the mock bus. 44 // Create a client with the mock bus.
44 client_.reset(ShillProfileClient::Create()); 45 client_.reset(ShillProfileClient::Create());
45 client_->Init(mock_bus_.get()); 46 client_->Init(mock_bus_.get());
46 // Run the message loop to run the signal connection result callback. 47 // Run the message loop to run the signal connection result callback.
47 message_loop_.RunUntilIdle(); 48 base::RunLoop().RunUntilIdle();
48 } 49 }
49 50
50 void TearDown() override { ShillClientUnittestBase::TearDown(); } 51 void TearDown() override { ShillClientUnittestBase::TearDown(); }
51 52
52 protected: 53 protected:
53 std::unique_ptr<ShillProfileClient> client_; 54 std::unique_ptr<ShillProfileClient> client_;
54 }; 55 };
55 56
56 TEST_F(ShillProfileClientTest, PropertyChanged) { 57 TEST_F(ShillProfileClientTest, PropertyChanged) {
57 // Create a signal. 58 // Create a signal.
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 response.get()); 116 response.get());
116 // Call method. 117 // Call method.
117 MockErrorCallback error_callback; 118 MockErrorCallback error_callback;
118 client_->GetProperties(dbus::ObjectPath(kDefaultProfilePath), 119 client_->GetProperties(dbus::ObjectPath(kDefaultProfilePath),
119 base::Bind(&ExpectDictionaryValueResultWithoutStatus, 120 base::Bind(&ExpectDictionaryValueResultWithoutStatus,
120 &value), 121 &value),
121 error_callback.GetCallback()); 122 error_callback.GetCallback());
122 EXPECT_CALL(error_callback, Run(_, _)).Times(0); 123 EXPECT_CALL(error_callback, Run(_, _)).Times(0);
123 124
124 // Run the message loop. 125 // Run the message loop.
125 message_loop_.RunUntilIdle(); 126 base::RunLoop().RunUntilIdle();
126 } 127 }
127 128
128 TEST_F(ShillProfileClientTest, GetEntry) { 129 TEST_F(ShillProfileClientTest, GetEntry) {
129 // Create response. 130 // Create response.
130 std::unique_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); 131 std::unique_ptr<dbus::Response> response(dbus::Response::CreateEmpty());
131 dbus::MessageWriter writer(response.get()); 132 dbus::MessageWriter writer(response.get());
132 dbus::MessageWriter array_writer(NULL); 133 dbus::MessageWriter array_writer(NULL);
133 writer.OpenArray("{sv}", &array_writer); 134 writer.OpenArray("{sv}", &array_writer);
134 dbus::MessageWriter entry_writer(NULL); 135 dbus::MessageWriter entry_writer(NULL);
135 array_writer.OpenDictEntry(&entry_writer); 136 array_writer.OpenDictEntry(&entry_writer);
(...skipping 12 matching lines...) Expand all
148 response.get()); 149 response.get());
149 // Call method. 150 // Call method.
150 MockErrorCallback error_callback; 151 MockErrorCallback error_callback;
151 client_->GetEntry(dbus::ObjectPath(kDefaultProfilePath), 152 client_->GetEntry(dbus::ObjectPath(kDefaultProfilePath),
152 kExampleEntryPath, 153 kExampleEntryPath,
153 base::Bind(&ExpectDictionaryValueResultWithoutStatus, 154 base::Bind(&ExpectDictionaryValueResultWithoutStatus,
154 &value), 155 &value),
155 error_callback.GetCallback()); 156 error_callback.GetCallback());
156 EXPECT_CALL(error_callback, Run(_, _)).Times(0); 157 EXPECT_CALL(error_callback, Run(_, _)).Times(0);
157 // Run the message loop. 158 // Run the message loop.
158 message_loop_.RunUntilIdle(); 159 base::RunLoop().RunUntilIdle();
159 } 160 }
160 161
161 TEST_F(ShillProfileClientTest, DeleteEntry) { 162 TEST_F(ShillProfileClientTest, DeleteEntry) {
162 // Create response. 163 // Create response.
163 std::unique_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); 164 std::unique_ptr<dbus::Response> response(dbus::Response::CreateEmpty());
164 165
165 // Create the expected value. 166 // Create the expected value.
166 base::DictionaryValue value; 167 base::DictionaryValue value;
167 value.SetWithoutPathExpansion(shill::kOfflineModeProperty, 168 value.SetWithoutPathExpansion(shill::kOfflineModeProperty,
168 new base::FundamentalValue(true)); 169 new base::FundamentalValue(true));
169 // Set expectations. 170 // Set expectations.
170 PrepareForMethodCall(shill::kDeleteEntryFunction, 171 PrepareForMethodCall(shill::kDeleteEntryFunction,
171 base::Bind(&ExpectStringArgument, kExampleEntryPath), 172 base::Bind(&ExpectStringArgument, kExampleEntryPath),
172 response.get()); 173 response.get());
173 // Call method. 174 // Call method.
174 MockClosure mock_closure; 175 MockClosure mock_closure;
175 MockErrorCallback mock_error_callback; 176 MockErrorCallback mock_error_callback;
176 client_->DeleteEntry(dbus::ObjectPath(kDefaultProfilePath), 177 client_->DeleteEntry(dbus::ObjectPath(kDefaultProfilePath),
177 kExampleEntryPath, 178 kExampleEntryPath,
178 mock_closure.GetCallback(), 179 mock_closure.GetCallback(),
179 mock_error_callback.GetCallback()); 180 mock_error_callback.GetCallback());
180 EXPECT_CALL(mock_closure, Run()).Times(1); 181 EXPECT_CALL(mock_closure, Run()).Times(1);
181 EXPECT_CALL(mock_error_callback, Run(_, _)).Times(0); 182 EXPECT_CALL(mock_error_callback, Run(_, _)).Times(0);
182 183
183 // Run the message loop. 184 // Run the message loop.
184 message_loop_.RunUntilIdle(); 185 base::RunLoop().RunUntilIdle();
185 } 186 }
186 187
187 } // namespace chromeos 188 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698