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

Unified Diff: dbus/property_unittest.cc

Issue 523623003: Plug some of the leaks in dbus_unittests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: run_loop_->Quit() Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « dbus/object_manager_unittest.cc ('k') | dbus/signal_sender_verification_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dbus/property_unittest.cc
diff --git a/dbus/property_unittest.cc b/dbus/property_unittest.cc
index e078c0044d1f9a16e1193b39cca05c3eefc0ebfe..879a9a606652facc312b2142b112477b29a187a2 100644
--- a/dbus/property_unittest.cc
+++ b/dbus/property_unittest.cc
@@ -11,6 +11,7 @@
#include "base/bind.h"
#include "base/logging.h"
#include "base/message_loop/message_loop.h"
+#include "base/run_loop.h"
#include "base/threading/thread.h"
#include "base/threading/thread_restrictions.h"
#include "dbus/bus.h"
@@ -105,20 +106,22 @@ class PropertyTest : public testing::Test {
// waited for.
void PropertyCallback(const std::string& id, bool success) {
last_callback_ = id;
- message_loop_.Quit();
+ run_loop_->Quit();
}
protected:
// Called when a property value is updated.
void OnPropertyChanged(const std::string& name) {
updated_properties_.push_back(name);
- message_loop_.Quit();
+ run_loop_->Quit();
}
// Waits for the given number of updates.
void WaitForUpdates(size_t num_updates) {
- while (updated_properties_.size() < num_updates)
- message_loop_.Run();
+ while (updated_properties_.size() < num_updates) {
+ run_loop_.reset(new base::RunLoop);
+ run_loop_->Run();
+ }
for (size_t i = 0; i < num_updates; ++i)
updated_properties_.erase(updated_properties_.begin());
}
@@ -136,11 +139,13 @@ class PropertyTest : public testing::Test {
// other; you can set this to whatever you wish.
void WaitForCallback(const std::string& id) {
while (last_callback_ != id) {
- message_loop_.Run();
+ run_loop_.reset(new base::RunLoop);
+ run_loop_->Run();
}
}
base::MessageLoop message_loop_;
+ scoped_ptr<base::RunLoop> run_loop_;
scoped_ptr<base::Thread> dbus_thread_;
scoped_refptr<Bus> bus_;
ObjectProxy* object_proxy_;
« no previous file with comments | « dbus/object_manager_unittest.cc ('k') | dbus/signal_sender_verification_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698