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