OLD | NEW |
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" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 } | 44 } |
45 }; | 45 }; |
46 | 46 |
47 virtual void SetUp() { | 47 virtual void SetUp() { |
48 // Make the main thread not to allow IO. | 48 // Make the main thread not to allow IO. |
49 base::ThreadRestrictions::SetIOAllowed(false); | 49 base::ThreadRestrictions::SetIOAllowed(false); |
50 | 50 |
51 // Start the D-Bus thread. | 51 // Start the D-Bus thread. |
52 dbus_thread_.reset(new base::Thread("D-Bus Thread")); | 52 dbus_thread_.reset(new base::Thread("D-Bus Thread")); |
53 base::Thread::Options thread_options; | 53 base::Thread::Options thread_options; |
54 thread_options.message_loop_type = MessageLoop::TYPE_IO; | 54 thread_options.message_loop_type = base::MessageLoop::TYPE_IO; |
55 ASSERT_TRUE(dbus_thread_->StartWithOptions(thread_options)); | 55 ASSERT_TRUE(dbus_thread_->StartWithOptions(thread_options)); |
56 | 56 |
57 // Start the test service, using the D-Bus thread. | 57 // Start the test service, using the D-Bus thread. |
58 dbus::TestService::Options options; | 58 dbus::TestService::Options options; |
59 options.dbus_task_runner = dbus_thread_->message_loop_proxy(); | 59 options.dbus_task_runner = dbus_thread_->message_loop_proxy(); |
60 test_service_.reset(new dbus::TestService(options)); | 60 test_service_.reset(new dbus::TestService(options)); |
61 ASSERT_TRUE(test_service_->StartService()); | 61 ASSERT_TRUE(test_service_->StartService()); |
62 ASSERT_TRUE(test_service_->WaitUntilServiceIsStarted()); | 62 ASSERT_TRUE(test_service_->WaitUntilServiceIsStarted()); |
63 ASSERT_TRUE(test_service_->HasDBusThread()); | 63 ASSERT_TRUE(test_service_->HasDBusThread()); |
64 | 64 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 | 129 |
130 // Waits for the callback. |id| is the string bound to the callback when | 130 // Waits for the callback. |id| is the string bound to the callback when |
131 // the method call is made that identifies it and distinguishes from any | 131 // the method call is made that identifies it and distinguishes from any |
132 // other; you can set this to whatever you wish. | 132 // other; you can set this to whatever you wish. |
133 void WaitForCallback(const std::string& id) { | 133 void WaitForCallback(const std::string& id) { |
134 while (last_callback_ != id) { | 134 while (last_callback_ != id) { |
135 message_loop_.Run(); | 135 message_loop_.Run(); |
136 } | 136 } |
137 } | 137 } |
138 | 138 |
139 MessageLoop message_loop_; | 139 base::MessageLoop message_loop_; |
140 scoped_ptr<base::Thread> dbus_thread_; | 140 scoped_ptr<base::Thread> dbus_thread_; |
141 scoped_refptr<dbus::Bus> bus_; | 141 scoped_refptr<dbus::Bus> bus_; |
142 dbus::ObjectProxy* object_proxy_; | 142 dbus::ObjectProxy* object_proxy_; |
143 scoped_ptr<Properties> properties_; | 143 scoped_ptr<Properties> properties_; |
144 scoped_ptr<dbus::TestService> test_service_; | 144 scoped_ptr<dbus::TestService> test_service_; |
145 // Properties updated. | 145 // Properties updated. |
146 std::vector<std::string> updated_properties_; | 146 std::vector<std::string> updated_properties_; |
147 // Last callback received. | 147 // Last callback received. |
148 std::string last_callback_; | 148 std::string last_callback_; |
149 }; | 149 }; |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 base::Bind(&PropertyTest::PropertyCallback, | 238 base::Bind(&PropertyTest::PropertyCallback, |
239 base::Unretained(this), | 239 base::Unretained(this), |
240 "Set")); | 240 "Set")); |
241 WaitForCallback("Set"); | 241 WaitForCallback("Set"); |
242 | 242 |
243 // TestService sends a property update. | 243 // TestService sends a property update. |
244 WaitForUpdates(1); | 244 WaitForUpdates(1); |
245 | 245 |
246 EXPECT_EQ("NewService", properties_->name.value()); | 246 EXPECT_EQ("NewService", properties_->name.value()); |
247 } | 247 } |
OLD | NEW |