OLD | NEW |
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/run_loop.h" |
7 #include "base/values.h" | 7 #include "base/values.h" |
8 #include "chromeos/dbus/shill_client_unittest_base.h" | 8 #include "chromeos/dbus/shill_client_unittest_base.h" |
9 #include "chromeos/dbus/shill_service_client.h" | 9 #include "chromeos/dbus/shill_service_client.h" |
10 #include "dbus/message.h" | 10 #include "dbus/message.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 TEST_F(ShillServiceClientTest, PropertyChanged) { | 49 TEST_F(ShillServiceClientTest, PropertyChanged) { |
50 const int kValue = 42; | 50 const int kValue = 42; |
51 // Create a signal. | 51 // Create a signal. |
52 dbus::Signal signal(shill::kFlimflamServiceInterface, | 52 dbus::Signal signal(shill::kFlimflamServiceInterface, |
53 shill::kMonitorPropertyChanged); | 53 shill::kMonitorPropertyChanged); |
54 dbus::MessageWriter writer(&signal); | 54 dbus::MessageWriter writer(&signal); |
55 writer.AppendString(shill::kSignalStrengthProperty); | 55 writer.AppendString(shill::kSignalStrengthProperty); |
56 writer.AppendVariantOfByte(kValue); | 56 writer.AppendVariantOfByte(kValue); |
57 | 57 |
58 // Set expectations. | 58 // Set expectations. |
59 const base::FundamentalValue value(kValue); | 59 const base::Value value(kValue); |
60 MockPropertyChangeObserver observer; | 60 MockPropertyChangeObserver observer; |
61 EXPECT_CALL(observer, | 61 EXPECT_CALL(observer, |
62 OnPropertyChanged( | 62 OnPropertyChanged( |
63 shill::kSignalStrengthProperty, | 63 shill::kSignalStrengthProperty, |
64 ValueEq(ByRef(value)))).Times(1); | 64 ValueEq(ByRef(value)))).Times(1); |
65 | 65 |
66 // Add the observer | 66 // Add the observer |
67 client_->AddPropertyChangedObserver( | 67 client_->AddPropertyChangedObserver( |
68 dbus::ObjectPath(kExampleServicePath), | 68 dbus::ObjectPath(kExampleServicePath), |
69 &observer); | 69 &observer); |
(...skipping 22 matching lines...) Expand all Loading... |
92 dbus::MessageWriter entry_writer(NULL); | 92 dbus::MessageWriter entry_writer(NULL); |
93 array_writer.OpenDictEntry(&entry_writer); | 93 array_writer.OpenDictEntry(&entry_writer); |
94 entry_writer.AppendString(shill::kSignalStrengthProperty); | 94 entry_writer.AppendString(shill::kSignalStrengthProperty); |
95 entry_writer.AppendVariantOfByte(kValue); | 95 entry_writer.AppendVariantOfByte(kValue); |
96 array_writer.CloseContainer(&entry_writer); | 96 array_writer.CloseContainer(&entry_writer); |
97 writer.CloseContainer(&array_writer); | 97 writer.CloseContainer(&array_writer); |
98 | 98 |
99 // Set expectations. | 99 // Set expectations. |
100 base::DictionaryValue value; | 100 base::DictionaryValue value; |
101 value.SetWithoutPathExpansion(shill::kSignalStrengthProperty, | 101 value.SetWithoutPathExpansion(shill::kSignalStrengthProperty, |
102 new base::FundamentalValue(kValue)); | 102 new base::Value(kValue)); |
103 PrepareForMethodCall(shill::kGetPropertiesFunction, | 103 PrepareForMethodCall(shill::kGetPropertiesFunction, |
104 base::Bind(&ExpectNoArgument), | 104 base::Bind(&ExpectNoArgument), |
105 response.get()); | 105 response.get()); |
106 // Call method. | 106 // Call method. |
107 client_->GetProperties(dbus::ObjectPath(kExampleServicePath), | 107 client_->GetProperties(dbus::ObjectPath(kExampleServicePath), |
108 base::Bind(&ExpectDictionaryValueResult, &value)); | 108 base::Bind(&ExpectDictionaryValueResult, &value)); |
109 // Run the message loop. | 109 // Run the message loop. |
110 base::RunLoop().RunUntilIdle(); | 110 base::RunLoop().RunUntilIdle(); |
111 } | 111 } |
112 | 112 |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 mock_closure.GetCallback(), | 297 mock_closure.GetCallback(), |
298 mock_error_callback.GetCallback()); | 298 mock_error_callback.GetCallback()); |
299 EXPECT_CALL(mock_closure, Run()).Times(1); | 299 EXPECT_CALL(mock_closure, Run()).Times(1); |
300 EXPECT_CALL(mock_error_callback, Run(_, _)).Times(0); | 300 EXPECT_CALL(mock_error_callback, Run(_, _)).Times(0); |
301 | 301 |
302 // Run the message loop. | 302 // Run the message loop. |
303 base::RunLoop().RunUntilIdle(); | 303 base::RunLoop().RunUntilIdle(); |
304 } | 304 } |
305 | 305 |
306 } // namespace chromeos | 306 } // namespace chromeos |
OLD | NEW |