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

Side by Side Diff: dbus/end_to_end_async_unittest.cc

Issue 7830009: Add Bus::ShutdownOnDBusThreadAndBlock() and remove bus::Shutdown() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comments Created 9 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 | Annotate | Revision Log
« no previous file with comments | « dbus/bus_unittest.cc ('k') | dbus/end_to_end_sync_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <algorithm> 5 #include <algorithm>
6 #include <string> 6 #include <string>
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 "Test", 59 "Test",
60 base::Bind(&EndToEndAsyncTest::OnTestSignal, 60 base::Bind(&EndToEndAsyncTest::OnTestSignal,
61 base::Unretained(this)), 61 base::Unretained(this)),
62 base::Bind(&EndToEndAsyncTest::OnConnected, 62 base::Bind(&EndToEndAsyncTest::OnConnected,
63 base::Unretained(this))); 63 base::Unretained(this)));
64 // Wait until the object proxy is connected to the signal. 64 // Wait until the object proxy is connected to the signal.
65 message_loop_.Run(); 65 message_loop_.Run();
66 } 66 }
67 67
68 virtual void TearDown() { 68 virtual void TearDown() {
69 bus_->Shutdown(base::Bind(&EndToEndAsyncTest::OnShutdown, 69 bus_->ShutdownOnDBusThreadAndBlock();
70 base::Unretained(this)));
71 // Wait until the bus is shutdown. OnShutdown() will be called in
72 // message_loop_.
73 message_loop_.Run();
74 70
75 // Shut down the service. 71 // Shut down the service.
76 test_service_->Shutdown(); 72 test_service_->ShutdownAndBlock();
77 ASSERT_TRUE(test_service_->WaitUntilServiceIsShutdown());
78 73
79 // Reset to the default. 74 // Reset to the default.
80 base::ThreadRestrictions::SetIOAllowed(true); 75 base::ThreadRestrictions::SetIOAllowed(true);
81 76
82 // Stopping a thread is considered an IO operation, so do this after 77 // Stopping a thread is considered an IO operation, so do this after
83 // allowing IO. 78 // allowing IO.
84 test_service_->Stop(); 79 test_service_->Stop();
85 } 80 }
86 81
87 protected: 82 protected:
(...skipping 22 matching lines...) Expand all
110 dbus::MessageReader reader(response); 105 dbus::MessageReader reader(response);
111 std::string response_string; 106 std::string response_string;
112 ASSERT_TRUE(reader.PopString(&response_string)); 107 ASSERT_TRUE(reader.PopString(&response_string));
113 response_strings_.push_back(response_string); 108 response_strings_.push_back(response_string);
114 } else { 109 } else {
115 response_strings_.push_back(""); 110 response_strings_.push_back("");
116 } 111 }
117 message_loop_.Quit(); 112 message_loop_.Quit();
118 }; 113 };
119 114
120 // Called when the shutdown is complete.
121 void OnShutdown() {
122 message_loop_.Quit();
123 }
124
125 // Called when the "Test" signal is received, in the main thread. 115 // Called when the "Test" signal is received, in the main thread.
126 // Copy the string payload to |test_signal_string_|. 116 // Copy the string payload to |test_signal_string_|.
127 void OnTestSignal(dbus::Signal* signal) { 117 void OnTestSignal(dbus::Signal* signal) {
128 dbus::MessageReader reader(signal); 118 dbus::MessageReader reader(signal);
129 ASSERT_TRUE(reader.PopString(&test_signal_string_)); 119 ASSERT_TRUE(reader.PopString(&test_signal_string_));
130 message_loop_.Quit(); 120 message_loop_.Quit();
131 } 121 }
132 122
133 // Called when connected to the signal. 123 // Called when connected to the signal.
134 void OnConnected(const std::string& interface_name, 124 void OnConnected(const std::string& interface_name,
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 226
237 TEST_F(EndToEndAsyncTest, TestSignal) { 227 TEST_F(EndToEndAsyncTest, TestSignal) {
238 const char kMessage[] = "hello, world"; 228 const char kMessage[] = "hello, world";
239 // Send the test signal from the exported object. 229 // Send the test signal from the exported object.
240 test_service_->SendTestSignal(kMessage); 230 test_service_->SendTestSignal(kMessage);
241 // Receive the signal with the object proxy. The signal is handled in 231 // Receive the signal with the object proxy. The signal is handled in
242 // EndToEndAsyncTest::OnTestSignal() in the main thread. 232 // EndToEndAsyncTest::OnTestSignal() in the main thread.
243 WaitForTestSignal(); 233 WaitForTestSignal();
244 ASSERT_EQ(kMessage, test_signal_string_); 234 ASSERT_EQ(kMessage, test_signal_string_);
245 } 235 }
OLDNEW
« no previous file with comments | « dbus/bus_unittest.cc ('k') | dbus/end_to_end_sync_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698