| 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 <algorithm> |    5 #include <algorithm> | 
|    6 #include <string> |    6 #include <string> | 
|    7 #include <vector> |    7 #include <vector> | 
|    8  |    8  | 
|    9 #include "base/bind.h" |    9 #include "base/bind.h" | 
|   10 #include "base/memory/scoped_ptr.h" |   10 #include "base/memory/scoped_ptr.h" | 
| (...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  446  |  446  | 
|  447   const int timeout_ms = dbus::ObjectProxy::TIMEOUT_USE_DEFAULT; |  447   const int timeout_ms = dbus::ObjectProxy::TIMEOUT_USE_DEFAULT; | 
|  448   CallMethodWithErrorCallback(&method_call, timeout_ms); |  448   CallMethodWithErrorCallback(&method_call, timeout_ms); | 
|  449   WaitForErrors(1); |  449   WaitForErrors(1); | 
|  450  |  450  | 
|  451   // Should fail because the method is broken. |  451   // Should fail because the method is broken. | 
|  452   ASSERT_TRUE(response_strings_.empty()); |  452   ASSERT_TRUE(response_strings_.empty()); | 
|  453   ASSERT_EQ(DBUS_ERROR_FAILED, error_names_[0]); |  453   ASSERT_EQ(DBUS_ERROR_FAILED, error_names_[0]); | 
|  454 } |  454 } | 
|  455  |  455  | 
 |  456 TEST_F(EndToEndAsyncTest, InvalidObjectPath) { | 
 |  457   // Trailing '/' is only allowed for the root path. | 
 |  458   const dbus::ObjectPath invalid_object_path("/org/chromium/TestObject/"); | 
 |  459  | 
 |  460   // Replace object proxy with new one. | 
 |  461   object_proxy_ = bus_->GetObjectProxy("org.chromium.TestService", | 
 |  462                                        invalid_object_path); | 
 |  463  | 
 |  464   dbus::MethodCall method_call("org.chromium.TestInterface", "Echo"); | 
 |  465  | 
 |  466   const int timeout_ms = dbus::ObjectProxy::TIMEOUT_USE_DEFAULT; | 
 |  467   CallMethodWithErrorCallback(&method_call, timeout_ms); | 
 |  468   WaitForErrors(1); | 
 |  469  | 
 |  470   // Should fail because of the invalid path. | 
 |  471   ASSERT_TRUE(response_strings_.empty()); | 
 |  472   ASSERT_EQ("", error_names_[0]); | 
 |  473 } | 
 |  474  | 
 |  475 TEST_F(EndToEndAsyncTest, InvalidServiceName) { | 
 |  476   // Bus name cannot contain '/'. | 
 |  477   const std::string invalid_service_name = ":1/2"; | 
 |  478  | 
 |  479   // Replace object proxy with new one. | 
 |  480   object_proxy_ = bus_->GetObjectProxy( | 
 |  481       invalid_service_name, dbus::ObjectPath("org.chromium.TestObject")); | 
 |  482  | 
 |  483   dbus::MethodCall method_call("org.chromium.TestInterface", "Echo"); | 
 |  484  | 
 |  485   const int timeout_ms = dbus::ObjectProxy::TIMEOUT_USE_DEFAULT; | 
 |  486   CallMethodWithErrorCallback(&method_call, timeout_ms); | 
 |  487   WaitForErrors(1); | 
 |  488  | 
 |  489   // Should fail because of the invalid bus name. | 
 |  490   ASSERT_TRUE(response_strings_.empty()); | 
 |  491   ASSERT_EQ("", error_names_[0]); | 
 |  492 } | 
 |  493  | 
|  456 TEST_F(EndToEndAsyncTest, EmptyResponseCallback) { |  494 TEST_F(EndToEndAsyncTest, EmptyResponseCallback) { | 
|  457   const char* kHello = "hello"; |  495   const char* kHello = "hello"; | 
|  458  |  496  | 
|  459   // Create the method call. |  497   // Create the method call. | 
|  460   dbus::MethodCall method_call("org.chromium.TestInterface", "Echo"); |  498   dbus::MethodCall method_call("org.chromium.TestInterface", "Echo"); | 
|  461   dbus::MessageWriter writer(&method_call); |  499   dbus::MessageWriter writer(&method_call); | 
|  462   writer.AppendString(kHello); |  500   writer.AppendString(kHello); | 
|  463  |  501  | 
|  464   // Call the method with an empty callback. |  502   // Call the method with an empty callback. | 
|  465   const int timeout_ms = dbus::ObjectProxy::TIMEOUT_USE_DEFAULT; |  503   const int timeout_ms = dbus::ObjectProxy::TIMEOUT_USE_DEFAULT; | 
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  547   const char kMessage[] = "hello, world"; |  585   const char kMessage[] = "hello, world"; | 
|  548   // Send the test signal from the exported object. |  586   // Send the test signal from the exported object. | 
|  549   test_service_->SendTestSignal(kMessage); |  587   test_service_->SendTestSignal(kMessage); | 
|  550   // Receive the signal with the object proxy. |  588   // Receive the signal with the object proxy. | 
|  551   WaitForTestSignal(); |  589   WaitForTestSignal(); | 
|  552   // Verify the string WAS NOT received by the original handler. |  590   // Verify the string WAS NOT received by the original handler. | 
|  553   ASSERT_TRUE(test_signal_string_.empty()); |  591   ASSERT_TRUE(test_signal_string_.empty()); | 
|  554   // Verify the signal WAS received by the replacement handler. |  592   // Verify the signal WAS received by the replacement handler. | 
|  555   ASSERT_EQ(kMessage, replacement_test_signal_string_); |  593   ASSERT_EQ(kMessage, replacement_test_signal_string_); | 
|  556 } |  594 } | 
| OLD | NEW |