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

Side by Side Diff: chromeos/dbus/shill_network_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_network_client.h" 8 #include "chromeos/dbus/shill_network_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 kExampleNetworkPath[] = "/foo/bar"; 21 const char kExampleNetworkPath[] = "/foo/bar";
19 22
20 } // namespace 23 } // namespace
21 24
22 class ShillNetworkClientTest : public ShillClientUnittestBase { 25 class ShillNetworkClientTest : public ShillClientUnittestBase {
23 public: 26 public:
(...skipping 23 matching lines...) Expand all
47 TEST_F(ShillNetworkClientTest, PropertyChanged) { 50 TEST_F(ShillNetworkClientTest, 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::kFlimflamNetworkInterface, 53 dbus::Signal signal(flimflam::kFlimflamNetworkInterface,
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(kExampleNetworkPath), 60 MockPropertyChangeObserver observer;
58 base::Bind(&ExpectPropertyChanged, 61 EXPECT_CALL(observer,
59 flimflam::kConnectedProperty, 62 OnPropertyChanged(
60 &kConnected)); 63 flimflam::kConnectedProperty,
64 ValueEq(ByRef(kConnected)))).Times(1);
65
66 // Add the observer
67 client_->AddPropertyChangedObserver(
68 dbus::ObjectPath(kExampleNetworkPath),
69 &observer);
70
61 // Run the signal callback. 71 // Run the signal callback.
62 SendPropertyChangedSignal(&signal); 72 SendPropertyChangedSignal(&signal);
63 73
64 // Reset the handler. 74 // Remove the observer.
65 client_->ResetPropertyChangedHandler(dbus::ObjectPath(kExampleNetworkPath)); 75 client_->RemovePropertyChangedObserver(
76 dbus::ObjectPath(kExampleNetworkPath),
77 &observer);
78
79 EXPECT_CALL(observer, OnPropertyChanged(_, _)).Times(0);
80
81 // Run the signal callback again and make sure the observer isn't called.
82 SendPropertyChangedSignal(&signal);
66 } 83 }
67 84
68 TEST_F(ShillNetworkClientTest, GetProperties) { 85 TEST_F(ShillNetworkClientTest, GetProperties) {
69 const char kAddress[] = "address"; 86 const char kAddress[] = "address";
70 const char kName[] = "name"; 87 const char kName[] = "name";
71 const uint8 kSignalStrength = 1; 88 const uint8 kSignalStrength = 1;
72 const uint32 kWifiChannel = 1; 89 const uint32 kWifiChannel = 1;
73 const bool kConnected = true; 90 const bool kConnected = true;
74 91
75 // Create response. 92 // Create response.
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 // Call method. 175 // Call method.
159 scoped_ptr<base::DictionaryValue> result( 176 scoped_ptr<base::DictionaryValue> result(
160 client_->CallGetPropertiesAndBlock( 177 client_->CallGetPropertiesAndBlock(
161 dbus::ObjectPath(kExampleNetworkPath))); 178 dbus::ObjectPath(kExampleNetworkPath)));
162 179
163 ASSERT_TRUE(result.get()); 180 ASSERT_TRUE(result.get());
164 EXPECT_TRUE(result->Equals(&value)); 181 EXPECT_TRUE(result->Equals(&value));
165 } 182 }
166 183
167 } // namespace chromeos 184 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698