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

Side by Side Diff: dbus/signal_sender_verification_unittest.cc

Issue 1179163002: Migrate callers of message_loop_proxy() to task_runner() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 5 years, 6 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
« no previous file with comments | « dbus/property_unittest.cc ('k') | dbus/test_server.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) 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/memory/scoped_ptr.h" 6 #include "base/memory/scoped_ptr.h"
7 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "base/metrics/histogram_samples.h" 9 #include "base/metrics/histogram_samples.h"
10 #include "base/metrics/statistics_recorder.h" 10 #include "base/metrics/statistics_recorder.h"
(...skipping 26 matching lines...) Expand all
37 // Start the D-Bus thread. 37 // Start the D-Bus thread.
38 dbus_thread_.reset(new base::Thread("D-Bus Thread")); 38 dbus_thread_.reset(new base::Thread("D-Bus Thread"));
39 base::Thread::Options thread_options; 39 base::Thread::Options thread_options;
40 thread_options.message_loop_type = base::MessageLoop::TYPE_IO; 40 thread_options.message_loop_type = base::MessageLoop::TYPE_IO;
41 ASSERT_TRUE(dbus_thread_->StartWithOptions(thread_options)); 41 ASSERT_TRUE(dbus_thread_->StartWithOptions(thread_options));
42 42
43 // Create the client, using the D-Bus thread. 43 // Create the client, using the D-Bus thread.
44 Bus::Options bus_options; 44 Bus::Options bus_options;
45 bus_options.bus_type = Bus::SESSION; 45 bus_options.bus_type = Bus::SESSION;
46 bus_options.connection_type = Bus::PRIVATE; 46 bus_options.connection_type = Bus::PRIVATE;
47 bus_options.dbus_task_runner = dbus_thread_->message_loop_proxy(); 47 bus_options.dbus_task_runner = dbus_thread_->task_runner();
48 bus_ = new Bus(bus_options); 48 bus_ = new Bus(bus_options);
49 object_proxy_ = bus_->GetObjectProxy( 49 object_proxy_ = bus_->GetObjectProxy(
50 "org.chromium.TestService", 50 "org.chromium.TestService",
51 ObjectPath("/org/chromium/TestObject")); 51 ObjectPath("/org/chromium/TestObject"));
52 ASSERT_TRUE(bus_->HasDBusThread()); 52 ASSERT_TRUE(bus_->HasDBusThread());
53 53
54 object_proxy_->SetNameOwnerChangedCallback( 54 object_proxy_->SetNameOwnerChangedCallback(
55 base::Bind(&SignalSenderVerificationTest::OnNameOwnerChanged, 55 base::Bind(&SignalSenderVerificationTest::OnNameOwnerChanged,
56 base::Unretained(this), 56 base::Unretained(this),
57 &on_name_owner_changed_called_)); 57 &on_name_owner_changed_called_));
58 58
59 // Connect to the "Test" signal of "org.chromium.TestInterface" from 59 // Connect to the "Test" signal of "org.chromium.TestInterface" from
60 // the remote object. 60 // the remote object.
61 object_proxy_->ConnectToSignal( 61 object_proxy_->ConnectToSignal(
62 "org.chromium.TestInterface", 62 "org.chromium.TestInterface",
63 "Test", 63 "Test",
64 base::Bind(&SignalSenderVerificationTest::OnTestSignal, 64 base::Bind(&SignalSenderVerificationTest::OnTestSignal,
65 base::Unretained(this)), 65 base::Unretained(this)),
66 base::Bind(&SignalSenderVerificationTest::OnConnected, 66 base::Bind(&SignalSenderVerificationTest::OnConnected,
67 base::Unretained(this))); 67 base::Unretained(this)));
68 // Wait until the object proxy is connected to the signal. 68 // Wait until the object proxy is connected to the signal.
69 run_loop_.reset(new base::RunLoop); 69 run_loop_.reset(new base::RunLoop);
70 run_loop_->Run(); 70 run_loop_->Run();
71 71
72 // Start the test service, using the D-Bus thread. 72 // Start the test service, using the D-Bus thread.
73 TestService::Options options; 73 TestService::Options options;
74 options.dbus_task_runner = dbus_thread_->message_loop_proxy(); 74 options.dbus_task_runner = dbus_thread_->task_runner();
75 test_service_.reset(new TestService(options)); 75 test_service_.reset(new TestService(options));
76 ASSERT_TRUE(test_service_->StartService()); 76 ASSERT_TRUE(test_service_->StartService());
77 ASSERT_TRUE(test_service_->WaitUntilServiceIsStarted()); 77 ASSERT_TRUE(test_service_->WaitUntilServiceIsStarted());
78 ASSERT_TRUE(test_service_->HasDBusThread()); 78 ASSERT_TRUE(test_service_->HasDBusThread());
79 ASSERT_TRUE(test_service_->has_ownership()); 79 ASSERT_TRUE(test_service_->has_ownership());
80 80
81 // Same setup for the second TestService. This service should not have the 81 // Same setup for the second TestService. This service should not have the
82 // ownership of the name at this point. 82 // ownership of the name at this point.
83 test_service2_.reset(new TestService(options)); 83 test_service2_.reset(new TestService(options));
84 ASSERT_TRUE(test_service2_->StartService()); 84 ASSERT_TRUE(test_service2_->StartService());
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 // OnNameOwnerChanged will PostTask to quit the message loop. 271 // OnNameOwnerChanged will PostTask to quit the message loop.
272 run_loop_.reset(new base::RunLoop); 272 run_loop_.reset(new base::RunLoop);
273 run_loop_->Run(); 273 run_loop_->Run();
274 // latest_name_owner_ should be empty as the owner is gone. 274 // latest_name_owner_ should be empty as the owner is gone.
275 ASSERT_TRUE(latest_name_owner_.empty()); 275 ASSERT_TRUE(latest_name_owner_.empty());
276 // Reset the flag as NameOwnerChanged is already received in setup. 276 // Reset the flag as NameOwnerChanged is already received in setup.
277 on_name_owner_changed_called_ = false; 277 on_name_owner_changed_called_ = false;
278 278
279 // Start a test service that allows theft, using the D-Bus thread. 279 // Start a test service that allows theft, using the D-Bus thread.
280 TestService::Options options; 280 TestService::Options options;
281 options.dbus_task_runner = dbus_thread_->message_loop_proxy(); 281 options.dbus_task_runner = dbus_thread_->task_runner();
282 options.request_ownership_options = Bus::REQUIRE_PRIMARY_ALLOW_REPLACEMENT; 282 options.request_ownership_options = Bus::REQUIRE_PRIMARY_ALLOW_REPLACEMENT;
283 TestService stealable_test_service(options); 283 TestService stealable_test_service(options);
284 ASSERT_TRUE(stealable_test_service.StartService()); 284 ASSERT_TRUE(stealable_test_service.StartService());
285 ASSERT_TRUE(stealable_test_service.WaitUntilServiceIsStarted()); 285 ASSERT_TRUE(stealable_test_service.WaitUntilServiceIsStarted());
286 ASSERT_TRUE(stealable_test_service.HasDBusThread()); 286 ASSERT_TRUE(stealable_test_service.HasDBusThread());
287 ASSERT_TRUE(stealable_test_service.has_ownership()); 287 ASSERT_TRUE(stealable_test_service.has_ownership());
288 288
289 // OnNameOwnerChanged will PostTask to quit the message loop. 289 // OnNameOwnerChanged will PostTask to quit the message loop.
290 run_loop_.reset(new base::RunLoop); 290 run_loop_.reset(new base::RunLoop);
291 run_loop_->Run(); 291 run_loop_->Run();
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 392
393 // Now the second service owns the name. 393 // Now the second service owns the name.
394 const char kNewMessage[] = "hello, new world"; 394 const char kNewMessage[] = "hello, new world";
395 395
396 test_service2_->SendTestSignal(kNewMessage); 396 test_service2_->SendTestSignal(kNewMessage);
397 WaitForTestSignal(); 397 WaitForTestSignal();
398 ASSERT_EQ(kNewMessage, test_signal_string_); 398 ASSERT_EQ(kNewMessage, test_signal_string_);
399 } 399 }
400 400
401 } // namespace dbus 401 } // namespace dbus
OLDNEW
« no previous file with comments | « dbus/property_unittest.cc ('k') | dbus/test_server.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698