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

Unified Diff: dbus/signal_sender_verification_unittest.cc

Issue 11299149: Revert 169164 - Allow multiple object proxies to handle NameOwnerChanged (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 1 month 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_proxy.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dbus/signal_sender_verification_unittest.cc
===================================================================
--- dbus/signal_sender_verification_unittest.cc (revision 169168)
+++ dbus/signal_sender_verification_unittest.cc (working copy)
@@ -51,8 +51,7 @@
object_proxy_->SetNameOwnerChangedCallback(
base::Bind(&SignalSenderVerificationTest::OnNameOwnerChanged,
- base::Unretained(this),
- &on_name_owner_changed_called_));
+ base::Unretained(this)));
// Connect to the "Test" signal of "org.chromium.TestInterface" from
// the remote object.
@@ -120,17 +119,19 @@
message_loop_.Quit();
}
- void OnNameOwnerChanged(bool* called_flag, dbus::Signal* signal) {
+ void OnNameOwnerChanged(dbus::Signal* signal) {
dbus::MessageReader reader(signal);
std::string name, old_owner, new_owner;
ASSERT_TRUE(reader.PopString(&name));
ASSERT_TRUE(reader.PopString(&old_owner));
ASSERT_TRUE(reader.PopString(&new_owner));
latest_name_owner_ = new_owner;
- *called_flag = true;
+ on_name_owner_changed_called_ = true;
message_loop_.Quit();
}
+ protected:
+
// Called when the "Test" signal is received, in the main thread.
// Copy the string payload to |test_signal_string_|.
void OnTestSignal(dbus::Signal* signal) {
@@ -147,8 +148,6 @@
message_loop_.Quit();
}
- protected:
-
// Wait for the hey signal to be received.
void WaitForTestSignal() {
// OnTestSignal() will quit the message loop.
@@ -246,73 +245,3 @@
WaitForTestSignal();
ASSERT_EQ(kNewMessage, test_signal_string_);
}
-
-TEST_F(SignalSenderVerificationTest, TestMultipleObjects) {
- const char kMessage[] = "hello, world";
-
- dbus::ObjectProxy* object_proxy2 = bus_->GetObjectProxy(
- "org.chromium.TestService",
- dbus::ObjectPath("/org/chromium/DifferentObject"));
-
- bool second_name_owner_changed_called = false;
- object_proxy2->SetNameOwnerChangedCallback(
- base::Bind(&SignalSenderVerificationTest::OnNameOwnerChanged,
- base::Unretained(this),
- &second_name_owner_changed_called));
-
- // Connect to a signal on the additional remote object to trigger the
- // name owner matching.
- object_proxy2->ConnectToSignal(
- "org.chromium.DifferentTestInterface",
- "Test",
- base::Bind(&SignalSenderVerificationTest::OnTestSignal,
- base::Unretained(this)),
- base::Bind(&SignalSenderVerificationTest::OnConnected,
- base::Unretained(this)));
- // Wait until the object proxy is connected to the signal.
- message_loop_.Run();
-
- // Send the test signal from the exported object.
- test_service_->SendTestSignal(kMessage);
- // Receive the signal with the object proxy. The signal is handled in
- // SignalSenderVerificationTest::OnTestSignal() in the main thread.
- WaitForTestSignal();
- ASSERT_EQ(kMessage, test_signal_string_);
-
- // Release and acquire the name ownership.
- // latest_name_owner_ should be non empty as |test_service_| owns the name.
- ASSERT_FALSE(latest_name_owner_.empty());
- test_service_->ShutdownAndBlock();
- // OnNameOwnerChanged will PostTask to quit the message loop.
- message_loop_.Run();
- // latest_name_owner_ should be empty as the owner is gone.
- ASSERT_TRUE(latest_name_owner_.empty());
-
- // Reset the flag as NameOwnerChanged is already received in setup.
- on_name_owner_changed_called_ = false;
- second_name_owner_changed_called = false;
- test_service2_->RequestOwnership(
- base::Bind(&SignalSenderVerificationTest::OnOwnership,
- base::Unretained(this), true));
- // Both of OnNameOwnerChanged() and OnOwnership() should quit the MessageLoop,
- // but there's no expected order of those 2 event.
- message_loop_.Run();
- if (!on_name_owner_changed_called_ || !on_ownership_called_)
- message_loop_.Run();
- ASSERT_TRUE(on_name_owner_changed_called_);
- ASSERT_TRUE(on_ownership_called_);
-
- // The callback for the second object must have also been called in the
- // same dispatch as for the first.
- ASSERT_TRUE(second_name_owner_changed_called);
-
- // latest_name_owner_ becomes non empty as the new owner appears.
- ASSERT_FALSE(latest_name_owner_.empty());
-
- // Now the second service owns the name.
- const char kNewMessage[] = "hello, new world";
-
- test_service2_->SendTestSignal(kNewMessage);
- WaitForTestSignal();
- ASSERT_EQ(kNewMessage, test_signal_string_);
-}
« no previous file with comments | « dbus/object_proxy.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698