| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/message.h" | 5 #include "dbus/message.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 } | 373 } |
| 374 | 374 |
| 375 TEST(MessageTest, Response) { | 375 TEST(MessageTest, Response) { |
| 376 dbus::Response response; | 376 dbus::Response response; |
| 377 EXPECT_TRUE(response.raw_message() == NULL); | 377 EXPECT_TRUE(response.raw_message() == NULL); |
| 378 response.reset_raw_message( | 378 response.reset_raw_message( |
| 379 dbus_message_new(DBUS_MESSAGE_TYPE_METHOD_RETURN)); | 379 dbus_message_new(DBUS_MESSAGE_TYPE_METHOD_RETURN)); |
| 380 EXPECT_EQ(dbus::Message::MESSAGE_METHOD_RETURN, response.GetMessageType()); | 380 EXPECT_EQ(dbus::Message::MESSAGE_METHOD_RETURN, response.GetMessageType()); |
| 381 } | 381 } |
| 382 | 382 |
| 383 TEST(MergeTest, Response_FromMethodCall) { | 383 TEST(MessageTest, Response_FromMethodCall) { |
| 384 const uint32 kSerial = 123; | 384 const uint32 kSerial = 123; |
| 385 dbus::MethodCall method_call("com.example.Interface", "SomeMethod"); | 385 dbus::MethodCall method_call("com.example.Interface", "SomeMethod"); |
| 386 method_call.SetSerial(kSerial); | 386 method_call.SetSerial(kSerial); |
| 387 | 387 |
| 388 scoped_ptr<dbus::Response> response( | 388 scoped_ptr<dbus::Response> response( |
| 389 dbus::Response::FromMethodCall(&method_call)); | 389 dbus::Response::FromMethodCall(&method_call)); |
| 390 EXPECT_EQ(dbus::Message::MESSAGE_METHOD_RETURN, response->GetMessageType()); | 390 EXPECT_EQ(dbus::Message::MESSAGE_METHOD_RETURN, response->GetMessageType()); |
| 391 // The serial should be copied to the reply serial. | 391 // The serial should be copied to the reply serial. |
| 392 EXPECT_EQ(kSerial, response->GetReplySerial()); | 392 EXPECT_EQ(kSerial, response->GetReplySerial()); |
| 393 } | 393 } |
| 394 | 394 |
| 395 TEST(MergeTest, ErrorResponse) { | 395 TEST(MessageTest, ErrorResponse) { |
| 396 dbus::ErrorResponse error_response; | 396 dbus::ErrorResponse error_response; |
| 397 EXPECT_TRUE(error_response.raw_message() == NULL); | 397 EXPECT_TRUE(error_response.raw_message() == NULL); |
| 398 error_response.reset_raw_message( | 398 error_response.reset_raw_message( |
| 399 dbus_message_new(DBUS_MESSAGE_TYPE_ERROR)); | 399 dbus_message_new(DBUS_MESSAGE_TYPE_ERROR)); |
| 400 EXPECT_EQ(dbus::Message::MESSAGE_ERROR, error_response.GetMessageType()); | 400 EXPECT_EQ(dbus::Message::MESSAGE_ERROR, error_response.GetMessageType()); |
| 401 } | 401 } |
| 402 | 402 |
| 403 TEST(MergeTest, ErrorResponse_FromMethodCall) { | 403 TEST(MessageTest, ErrorResponse_FromMethodCall) { |
| 404 const uint32 kSerial = 123; | 404 const uint32 kSerial = 123; |
| 405 const char kErrorMessage[] = "error message"; | 405 const char kErrorMessage[] = "error message"; |
| 406 | 406 |
| 407 dbus::MethodCall method_call("com.example.Interface", "SomeMethod"); | 407 dbus::MethodCall method_call("com.example.Interface", "SomeMethod"); |
| 408 method_call.SetSerial(kSerial); | 408 method_call.SetSerial(kSerial); |
| 409 | 409 |
| 410 scoped_ptr<dbus::ErrorResponse> error_response( | 410 scoped_ptr<dbus::ErrorResponse> error_response( |
| 411 dbus::ErrorResponse::FromMethodCall(&method_call, | 411 dbus::ErrorResponse::FromMethodCall(&method_call, |
| 412 DBUS_ERROR_FAILED, | 412 DBUS_ERROR_FAILED, |
| 413 kErrorMessage)); | 413 kErrorMessage)); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 451 | 451 |
| 452 EXPECT_EQ("org.chromium.destination", message.GetDestination()); | 452 EXPECT_EQ("org.chromium.destination", message.GetDestination()); |
| 453 EXPECT_EQ("/org/chromium/path", message.GetPath()); | 453 EXPECT_EQ("/org/chromium/path", message.GetPath()); |
| 454 EXPECT_EQ("org.chromium.interface", message.GetInterface()); | 454 EXPECT_EQ("org.chromium.interface", message.GetInterface()); |
| 455 EXPECT_EQ("member", message.GetMember()); | 455 EXPECT_EQ("member", message.GetMember()); |
| 456 EXPECT_EQ("org.chromium.error", message.GetErrorName()); | 456 EXPECT_EQ("org.chromium.error", message.GetErrorName()); |
| 457 EXPECT_EQ(":1.2", message.GetSender()); | 457 EXPECT_EQ(":1.2", message.GetSender()); |
| 458 EXPECT_EQ(123U, message.GetSerial()); | 458 EXPECT_EQ(123U, message.GetSerial()); |
| 459 EXPECT_EQ(456U, message.GetReplySerial()); | 459 EXPECT_EQ(456U, message.GetReplySerial()); |
| 460 } | 460 } |
| OLD | NEW |