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

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

Issue 10949030: This converts the Shill clients to allow propagation of shill errors (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 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/values.h" 6 #include "base/values.h"
7 #include "chromeos/dbus/shill_client_unittest_base.h" 7 #include "chromeos/dbus/shill_client_unittest_base.h"
8 #include "chromeos/dbus/shill_ipconfig_client.h" 8 #include "chromeos/dbus/shill_ipconfig_client.h"
9 #include "dbus/message.h" 9 #include "dbus/message.h"
10 #include "dbus/values_util.h" 10 #include "dbus/values_util.h"
11 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
12 #include "third_party/cros_system_api/dbus/service_constants.h" 12 #include "third_party/cros_system_api/dbus/service_constants.h"
13 13
14 using testing::_;
15 using testing::ByRef;
16
14 namespace chromeos { 17 namespace chromeos {
15 18
16 namespace { 19 namespace {
17 20
18 const char kExampleIPConfigPath[] = "/foo/bar"; 21 const char kExampleIPConfigPath[] = "/foo/bar";
19 22
20 } // namespace 23 } // namespace
21 24
22 class ShillIPConfigClientTest : public ShillClientUnittestBase { 25 class ShillIPConfigClientTest : public ShillClientUnittestBase {
23 public: 26 public:
(...skipping 23 matching lines...) Expand all
47 TEST_F(ShillIPConfigClientTest, PropertyChanged) { 50 TEST_F(ShillIPConfigClientTest, PropertyChanged) {
48 // Create a signal. 51 // Create a signal.
49 const base::FundamentalValue kConnected(true); 52 const base::FundamentalValue kConnected(true);
50 dbus::Signal signal(flimflam::kFlimflamIPConfigInterface, 53 dbus::Signal signal(flimflam::kFlimflamIPConfigInterface,
51 flimflam::kMonitorPropertyChanged); 54 flimflam::kMonitorPropertyChanged);
52 dbus::MessageWriter writer(&signal); 55 dbus::MessageWriter writer(&signal);
53 writer.AppendString(flimflam::kConnectedProperty); 56 writer.AppendString(flimflam::kConnectedProperty);
54 dbus::AppendBasicTypeValueDataAsVariant(&writer, kConnected); 57 dbus::AppendBasicTypeValueDataAsVariant(&writer, kConnected);
55 58
56 // Set expectations. 59 // Set expectations.
57 client_->SetPropertyChangedHandler(dbus::ObjectPath(kExampleIPConfigPath), 60 MockPropertyChangeObserver observer;
58 base::Bind(&ExpectPropertyChanged, 61 EXPECT_CALL(observer, OnPropertyChanged(flimflam::kConnectedProperty,
59 flimflam::kConnectedProperty, 62 ValueEq(ByRef(kConnected)))).Times(1);
60 &kConnected)); 63
64 // Add the observer
65 client_->AddPropertyChangedObserver(
66 dbus::ObjectPath(kExampleIPConfigPath),
67 &observer);
68
61 // Run the signal callback. 69 // Run the signal callback.
62 SendPropertyChangedSignal(&signal); 70 SendPropertyChangedSignal(&signal);
63 71
64 // Reset the handler. 72 // Remove the observer.
65 client_->ResetPropertyChangedHandler(dbus::ObjectPath(kExampleIPConfigPath)); 73 client_->RemovePropertyChangedObserver(
74 dbus::ObjectPath(kExampleIPConfigPath),
75 &observer);
76
77 EXPECT_CALL(observer, OnPropertyChanged(_, _)).Times(0);
78
79 // Run the signal callback again and make sure the observer isn't called.
80 SendPropertyChangedSignal(&signal);
66 } 81 }
67 82
68 TEST_F(ShillIPConfigClientTest, GetProperties) { 83 TEST_F(ShillIPConfigClientTest, GetProperties) {
69 const char kAddress[] = "address"; 84 const char kAddress[] = "address";
70 const int32 kMtu = 68; 85 const int32 kMtu = 68;
71 86
72 // Create response. 87 // Create response.
73 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); 88 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty());
74 dbus::MessageWriter writer(response.get()); 89 dbus::MessageWriter writer(response.get());
75 dbus::MessageWriter array_writer(NULL); 90 dbus::MessageWriter array_writer(NULL);
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 // Set expectations. 223 // Set expectations.
209 PrepareForMethodCall(flimflam::kRemoveConfigFunction, 224 PrepareForMethodCall(flimflam::kRemoveConfigFunction,
210 base::Bind(&ExpectNoArgument), 225 base::Bind(&ExpectNoArgument),
211 response.get()); 226 response.get());
212 // Call method. 227 // Call method.
213 EXPECT_TRUE(client_->CallRemoveAndBlock( 228 EXPECT_TRUE(client_->CallRemoveAndBlock(
214 dbus::ObjectPath(kExampleIPConfigPath))); 229 dbus::ObjectPath(kExampleIPConfigPath)));
215 } 230 }
216 231
217 } // namespace chromeos 232 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698