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

Side by Side Diff: net/base/network_change_notifier_linux_unittest.cc

Issue 8591021: Fix initial offline state response handling (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 &RunOnNotifierThreadHelper, callback, &event)); 73 &RunOnNotifierThreadHelper, callback, &event));
74 event.Wait(); 74 event.Wait();
75 // Run any tasks queued on the main thread, e.g. by 75 // Run any tasks queued on the main thread, e.g. by
76 // ObserverListThreadSafe. 76 // ObserverListThreadSafe.
77 MessageLoop::current()->RunAllPending(); 77 MessageLoop::current()->RunAllPending();
78 } 78 }
79 79
80 void SendResponse(uint32 state) { 80 void SendResponse(uint32 state) {
81 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); 81 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty());
82 dbus::MessageWriter writer(response.get()); 82 dbus::MessageWriter writer(response.get());
83 writer.AppendUint32(state); 83 writer.AppendVariantOfUint32(state);
84 RunOnNotifierThread(base::Bind(response_callback_, response.get())); 84 RunOnNotifierThread(base::Bind(response_callback_, response.get()));
85 } 85 }
86 86
87 void SendSignal(uint32 state) { 87 void SendSignal(uint32 state) {
88 dbus::Signal signal("org.freedesktop.NetworkManager", "StateChanged"); 88 dbus::Signal signal("org.freedesktop.NetworkManager", "StateChanged");
89 dbus::MessageWriter writer(&signal); 89 dbus::MessageWriter writer(&signal);
90 writer.AppendUint32(state); 90 writer.AppendUint32(state);
91 RunOnNotifierThread(base::Bind(signal_callback_, &signal)); 91 RunOnNotifierThread(base::Bind(signal_callback_, &signal));
92 } 92 }
93 93
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 TEST_F(NetworkChangeNotifierLinuxTest, InvalidResponse) { 218 TEST_F(NetworkChangeNotifierLinuxTest, InvalidResponse) {
219 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); 219 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty());
220 dbus::MessageWriter writer(response.get()); 220 dbus::MessageWriter writer(response.get());
221 writer.AppendUint16(20); // Uint16 instead of the expected Uint32 221 writer.AppendUint16(20); // Uint16 instead of the expected Uint32
222 RunOnNotifierThread(base::Bind(response_callback_, response.get())); 222 RunOnNotifierThread(base::Bind(response_callback_, response.get()));
223 EXPECT_FALSE(NetworkChangeNotifier::IsOffline()); 223 EXPECT_FALSE(NetworkChangeNotifier::IsOffline());
224 } 224 }
225 225
226 } // namespace 226 } // namespace
227 } // namespace net 227 } // namespace net
OLDNEW
« net/base/network_change_notifier_linux.cc ('K') | « net/base/network_change_notifier_linux.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698