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

Side by Side Diff: dbus/property_unittest.cc

Issue 12255043: DBus: Use TaskRunners instead of MessageLoopProxies. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: rebase Created 7 years, 10 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
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 "dbus/property.h" 5 #include "dbus/property.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/message_loop.h" 13 #include "base/message_loop.h"
14 #include "base/threading/thread.h" 14 #include "base/threading/thread.h"
15 #include "base/threading/thread_restrictions.h" 15 #include "base/threading/thread_restrictions.h"
16 #include "dbus/bus.h" 16 #include "dbus/bus.h"
17 #include "dbus/object_path.h" 17 #include "dbus/object_path.h"
18 #include "dbus/object_proxy.h" 18 #include "dbus/object_proxy.h"
19 #include "dbus/property.h"
20 #include "dbus/test_service.h" 19 #include "dbus/test_service.h"
21 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
22 21
23 // The property test exerises the asynchronous APIs in PropertySet and 22 // The property test exerises the asynchronous APIs in PropertySet and
24 // Property<>. 23 // Property<>.
25 class PropertyTest : public testing::Test { 24 class PropertyTest : public testing::Test {
26 public: 25 public:
27 PropertyTest() { 26 PropertyTest() {
28 } 27 }
29 28
(...skipping 20 matching lines...) Expand all
50 base::ThreadRestrictions::SetIOAllowed(false); 49 base::ThreadRestrictions::SetIOAllowed(false);
51 50
52 // Start the D-Bus thread. 51 // Start the D-Bus thread.
53 dbus_thread_.reset(new base::Thread("D-Bus Thread")); 52 dbus_thread_.reset(new base::Thread("D-Bus Thread"));
54 base::Thread::Options thread_options; 53 base::Thread::Options thread_options;
55 thread_options.message_loop_type = MessageLoop::TYPE_IO; 54 thread_options.message_loop_type = MessageLoop::TYPE_IO;
56 ASSERT_TRUE(dbus_thread_->StartWithOptions(thread_options)); 55 ASSERT_TRUE(dbus_thread_->StartWithOptions(thread_options));
57 56
58 // Start the test service, using the D-Bus thread. 57 // Start the test service, using the D-Bus thread.
59 dbus::TestService::Options options; 58 dbus::TestService::Options options;
60 options.dbus_thread_message_loop_proxy = dbus_thread_->message_loop_proxy(); 59 options.dbus_task_runner = dbus_thread_->message_loop_proxy();
61 test_service_.reset(new dbus::TestService(options)); 60 test_service_.reset(new dbus::TestService(options));
62 ASSERT_TRUE(test_service_->StartService()); 61 ASSERT_TRUE(test_service_->StartService());
63 ASSERT_TRUE(test_service_->WaitUntilServiceIsStarted()); 62 ASSERT_TRUE(test_service_->WaitUntilServiceIsStarted());
64 ASSERT_TRUE(test_service_->HasDBusThread()); 63 ASSERT_TRUE(test_service_->HasDBusThread());
65 64
66 // Create the client, using the D-Bus thread. 65 // Create the client, using the D-Bus thread.
67 dbus::Bus::Options bus_options; 66 dbus::Bus::Options bus_options;
68 bus_options.bus_type = dbus::Bus::SESSION; 67 bus_options.bus_type = dbus::Bus::SESSION;
69 bus_options.connection_type = dbus::Bus::PRIVATE; 68 bus_options.connection_type = dbus::Bus::PRIVATE;
70 bus_options.dbus_thread_message_loop_proxy = 69 bus_options.dbus_task_runner = dbus_thread_->message_loop_proxy();
71 dbus_thread_->message_loop_proxy();
72 bus_ = new dbus::Bus(bus_options); 70 bus_ = new dbus::Bus(bus_options);
73 object_proxy_ = bus_->GetObjectProxy( 71 object_proxy_ = bus_->GetObjectProxy(
74 "org.chromium.TestService", 72 "org.chromium.TestService",
75 dbus::ObjectPath("/org/chromium/TestObject")); 73 dbus::ObjectPath("/org/chromium/TestObject"));
76 ASSERT_TRUE(bus_->HasDBusThread()); 74 ASSERT_TRUE(bus_->HasDBusThread());
77 75
78 // Create the properties structure 76 // Create the properties structure
79 properties_.reset(new Properties( 77 properties_.reset(new Properties(
80 object_proxy_, 78 object_proxy_,
81 base::Bind(&PropertyTest::OnPropertyChanged, 79 base::Bind(&PropertyTest::OnPropertyChanged,
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 base::Bind(&PropertyTest::PropertyCallback, 238 base::Bind(&PropertyTest::PropertyCallback,
241 base::Unretained(this), 239 base::Unretained(this),
242 "Set")); 240 "Set"));
243 WaitForCallback("Set"); 241 WaitForCallback("Set");
244 242
245 // TestService sends a property update. 243 // TestService sends a property update.
246 WaitForUpdates(1); 244 WaitForUpdates(1);
247 245
248 EXPECT_EQ("NewService", properties_->name.value()); 246 EXPECT_EQ("NewService", properties_->name.value());
249 } 247 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698