| 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 "net/base/network_change_notifier_linux.h" | 5 #include "net/base/network_change_notifier_linux.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop_proxy.h" | 8 #include "base/message_loop_proxy.h" |
| 9 #include "base/synchronization/waitable_event.h" | 9 #include "base/synchronization/waitable_event.h" |
| 10 #include "dbus/mock_bus.h" | 10 #include "dbus/mock_bus.h" |
| 11 #include "dbus/mock_object_proxy.h" | 11 #include "dbus/mock_object_proxy.h" |
| 12 #include "dbus/message.h" | 12 #include "dbus/message.h" |
| 13 #include "dbus/object_path.h" | |
| 14 #include "testing/gmock/include/gmock/gmock.h" | 13 #include "testing/gmock/include/gmock/gmock.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 16 | 15 |
| 17 namespace net { | 16 namespace net { |
| 18 | 17 |
| 19 using testing::_; | 18 using testing::_; |
| 20 using testing::DoAll; | 19 using testing::DoAll; |
| 21 using testing::InvokeWithoutArgs; | 20 using testing::InvokeWithoutArgs; |
| 22 using testing::Return; | 21 using testing::Return; |
| 23 using testing::SaveArg; | 22 using testing::SaveArg; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 35 }; | 34 }; |
| 36 | 35 |
| 37 NetworkChangeNotifierLinuxTest() | 36 NetworkChangeNotifierLinuxTest() |
| 38 : initialized_(false, false) {} | 37 : initialized_(false, false) {} |
| 39 | 38 |
| 40 virtual void SetUp() { | 39 virtual void SetUp() { |
| 41 dbus::Bus::Options options; | 40 dbus::Bus::Options options; |
| 42 options.bus_type = dbus::Bus::SYSTEM; | 41 options.bus_type = dbus::Bus::SYSTEM; |
| 43 mock_bus_ = new dbus::MockBus(options); | 42 mock_bus_ = new dbus::MockBus(options); |
| 44 | 43 |
| 45 mock_object_proxy_ = new dbus::MockObjectProxy( | 44 mock_object_proxy_ = new dbus::MockObjectProxy(mock_bus_.get(), |
| 46 mock_bus_.get(), | 45 "service_name", |
| 47 "service_name", | 46 "service_path"); |
| 48 dbus::ObjectPath("service_path")); | |
| 49 EXPECT_CALL(*mock_bus_, GetObjectProxyWithOptions(_, _, _)) | 47 EXPECT_CALL(*mock_bus_, GetObjectProxyWithOptions(_, _, _)) |
| 50 .WillOnce(Return(mock_object_proxy_.get())); | 48 .WillOnce(Return(mock_object_proxy_.get())); |
| 51 | 49 |
| 52 EXPECT_CALL(*mock_object_proxy_, CallMethod(_, _, _)) | 50 EXPECT_CALL(*mock_object_proxy_, CallMethod(_, _, _)) |
| 53 .WillOnce(SaveArg<2>(&response_callback_)); | 51 .WillOnce(SaveArg<2>(&response_callback_)); |
| 54 EXPECT_CALL(*mock_object_proxy_, ConnectToSignal(_, _, _, _)) | 52 EXPECT_CALL(*mock_object_proxy_, ConnectToSignal(_, _, _, _)) |
| 55 .WillOnce( | 53 .WillOnce( |
| 56 DoAll( | 54 DoAll( |
| 57 SaveArg<2>(&signal_callback_), | 55 SaveArg<2>(&signal_callback_), |
| 58 InvokeWithoutArgs( | 56 InvokeWithoutArgs( |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 TEST_F(NetworkChangeNotifierLinuxTest, InvalidResponse) { | 218 TEST_F(NetworkChangeNotifierLinuxTest, InvalidResponse) { |
| 221 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); | 219 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); |
| 222 dbus::MessageWriter writer(response.get()); | 220 dbus::MessageWriter writer(response.get()); |
| 223 writer.AppendUint16(20); // Uint16 instead of the expected Uint32 | 221 writer.AppendUint16(20); // Uint16 instead of the expected Uint32 |
| 224 RunOnNotifierThread(base::Bind(response_callback_, response.get())); | 222 RunOnNotifierThread(base::Bind(response_callback_, response.get())); |
| 225 EXPECT_FALSE(NetworkChangeNotifier::IsOffline()); | 223 EXPECT_FALSE(NetworkChangeNotifier::IsOffline()); |
| 226 } | 224 } |
| 227 | 225 |
| 228 } // namespace | 226 } // namespace |
| 229 } // namespace net | 227 } // namespace net |
| OLD | NEW |