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 3 // found in the LICENSE file. 4 5 #include "chrome/browser/chromeos/dbus/printer_service_provider.h" 6 7 #include "chrome/browser/chromeos/dbus/service_provider_test_helper.h" 8 #include "dbus/message.h" 9 #include "third_party/cros_system_api/dbus/service_constants.h" 10 11 namespace chromeos { 12 13 const char kPrinterAdded[] = "PrinterAdded"; 14 15 class MockPrinterServiceProvider : public PrinterServiceProvider { 16 public: 17 MOCK_METHOD2(ShowCloudPrintHelp, 18 void(const std::string& vendor, const std::string& product)); 19 }; 20 21 class PrinterServiceProviderTest : public testing::Test { 22 public: 23 virtual void SetUp() OVERRIDE { 24 test_helper_.SetUp(kPrinterAdded, &service_provider_); 25 } 26 27 virtual void TearDown() OVERRIDE { 28 test_helper_.TearDown(); 29 } 30 31 protected: 32 MockPrinterServiceProvider service_provider_; 33 ServiceProviderTestHelper test_helper_; 34 }; 35 36 TEST_F(PrinterServiceProviderTest, ShowCloudPrintHelp) { 37 dbus::MethodCall method_call(kLibCrosServiceInterface, kPrinterAdded); 38 dbus::MessageWriter writer(&method_call); 39 writer.AppendString("123"); 40 writer.AppendString("456"); 41 42 EXPECT_CALL(service_provider_, ShowCloudPrintHelp("123", "456")) 43 .Times(1); 44 45 // Call the PrinterAdded method. 46 scoped_ptr<dbus::Response> response(test_helper_.CallMethod(&method_call)); 47 48 // An empty response should be returned. 49 ASSERT_TRUE(response.get()); 50 dbus::MessageReader reader(response.get()); 51 ASSERT_FALSE(reader.HasMoreData()); 52 } 53 54 } // namespace chromeos 55 56