| 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/bus.h" | 5 #include "dbus/bus.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 bus->ListenForServiceOwnerChange("org.chromium.TestService", callback1); | 365 bus->ListenForServiceOwnerChange("org.chromium.TestService", callback1); |
| 366 // This should be a no-op. | 366 // This should be a no-op. |
| 367 bus->ListenForServiceOwnerChange("org.chromium.TestService", callback1); | 367 bus->ListenForServiceOwnerChange("org.chromium.TestService", callback1); |
| 368 base::RunLoop().RunUntilIdle(); | 368 base::RunLoop().RunUntilIdle(); |
| 369 | 369 |
| 370 // Nothing has happened yet. Check initial state. | 370 // Nothing has happened yet. Check initial state. |
| 371 EXPECT_TRUE(service_owner1.empty()); | 371 EXPECT_TRUE(service_owner1.empty()); |
| 372 EXPECT_EQ(0, num_of_owner_changes1); | 372 EXPECT_EQ(0, num_of_owner_changes1); |
| 373 | 373 |
| 374 // Make an ownership change. | 374 // Make an ownership change. |
| 375 ASSERT_TRUE(bus->RequestOwnershipAndBlock("org.chromium.TestService")); | 375 ASSERT_TRUE(bus->RequestOwnershipAndBlock("org.chromium.TestService", |
| 376 Bus::REQUIRE_PRIMARY)); |
| 376 run_loop_state.Run(1); | 377 run_loop_state.Run(1); |
| 377 | 378 |
| 378 { | 379 { |
| 379 // Get the current service owner and check to make sure the listener got | 380 // Get the current service owner and check to make sure the listener got |
| 380 // the right value. | 381 // the right value. |
| 381 std::string current_service_owner = | 382 std::string current_service_owner = |
| 382 bus->GetServiceOwnerAndBlock("org.chromium.TestService", | 383 bus->GetServiceOwnerAndBlock("org.chromium.TestService", |
| 383 Bus::REPORT_ERRORS); | 384 Bus::REPORT_ERRORS); |
| 384 ASSERT_FALSE(current_service_owner.empty()); | 385 ASSERT_FALSE(current_service_owner.empty()); |
| 385 | 386 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 415 bus->UnlistenForServiceOwnerChange("org.chromium.TestService", callback1); | 416 bus->UnlistenForServiceOwnerChange("org.chromium.TestService", callback1); |
| 416 bus->UnlistenForServiceOwnerChange("org.chromium.TestService", callback2); | 417 bus->UnlistenForServiceOwnerChange("org.chromium.TestService", callback2); |
| 417 base::RunLoop().RunUntilIdle(); | 418 base::RunLoop().RunUntilIdle(); |
| 418 | 419 |
| 419 // Shut down synchronously. | 420 // Shut down synchronously. |
| 420 bus->ShutdownAndBlock(); | 421 bus->ShutdownAndBlock(); |
| 421 EXPECT_TRUE(bus->shutdown_completed()); | 422 EXPECT_TRUE(bus->shutdown_completed()); |
| 422 } | 423 } |
| 423 | 424 |
| 424 } // namespace dbus | 425 } // namespace dbus |
| OLD | NEW |