| 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 // This test is relatively complicated. Here's the summary of what it does: | 5 // This test is relatively complicated. Here's the summary of what it does: |
| 6 // | 6 // |
| 7 // - Set up mock D-Bus related objects to mock out D-Bus calls. | 7 // - Set up mock D-Bus related objects to mock out D-Bus calls. |
| 8 // - Set up a mock proxy resolver to mock out the proxy resolution. | 8 // - Set up a mock proxy resolver to mock out the proxy resolution. |
| 9 // - Create ProxyResolutionServiceProvider by injecting the mocks | 9 // - Create ProxyResolutionServiceProvider by injecting the mocks |
| 10 // - Start the service provider. | 10 // - Start the service provider. |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 const std::string& signal_name, | 48 const std::string& signal_name, |
| 49 scoped_refptr<dbus::ExportedObject> exported_object)); | 49 scoped_refptr<dbus::ExportedObject> exported_object)); |
| 50 }; | 50 }; |
| 51 | 51 |
| 52 class ProxyResolutionServiceProviderTest : public testing::Test { | 52 class ProxyResolutionServiceProviderTest : public testing::Test { |
| 53 public: | 53 public: |
| 54 ProxyResolutionServiceProviderTest() | 54 ProxyResolutionServiceProviderTest() |
| 55 : signal_received_successfully_(false) { | 55 : signal_received_successfully_(false) { |
| 56 } | 56 } |
| 57 | 57 |
| 58 virtual void SetUp() OVERRIDE { | 58 virtual void SetUp() override { |
| 59 // Create a mock proxy resolver. Will be owned by | 59 // Create a mock proxy resolver. Will be owned by |
| 60 // |proxy_resolution_service|. | 60 // |proxy_resolution_service|. |
| 61 MockProxyResolver* mock_resolver = new MockProxyResolver; | 61 MockProxyResolver* mock_resolver = new MockProxyResolver; |
| 62 // |mock_resolver_|'s ResolveProxy() will use MockResolveProxy(). | 62 // |mock_resolver_|'s ResolveProxy() will use MockResolveProxy(). |
| 63 EXPECT_CALL(*mock_resolver, | 63 EXPECT_CALL(*mock_resolver, |
| 64 ResolveProxy(kSourceURL, kReturnSignalInterface, | 64 ResolveProxy(kSourceURL, kReturnSignalInterface, |
| 65 kReturnSignalName, _)) | 65 kReturnSignalName, _)) |
| 66 .WillOnce(Invoke( | 66 .WillOnce(Invoke( |
| 67 this, | 67 this, |
| 68 &ProxyResolutionServiceProviderTest::MockResolveProxy)); | 68 &ProxyResolutionServiceProviderTest::MockResolveProxy)); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 79 // signal. OnSignalReceived() will be called upon the delivery. | 79 // signal. OnSignalReceived() will be called upon the delivery. |
| 80 test_helper_.SetUpReturnSignal( | 80 test_helper_.SetUpReturnSignal( |
| 81 kReturnSignalInterface, | 81 kReturnSignalInterface, |
| 82 kReturnSignalName, | 82 kReturnSignalName, |
| 83 base::Bind(&ProxyResolutionServiceProviderTest::OnSignalReceived, | 83 base::Bind(&ProxyResolutionServiceProviderTest::OnSignalReceived, |
| 84 base::Unretained(this)), | 84 base::Unretained(this)), |
| 85 base::Bind(&ProxyResolutionServiceProviderTest::OnConnectedToSignal, | 85 base::Bind(&ProxyResolutionServiceProviderTest::OnConnectedToSignal, |
| 86 base::Unretained(this))); | 86 base::Unretained(this))); |
| 87 } | 87 } |
| 88 | 88 |
| 89 virtual void TearDown() OVERRIDE { | 89 virtual void TearDown() override { |
| 90 test_helper_.TearDown(); | 90 test_helper_.TearDown(); |
| 91 service_provider_.reset(); | 91 service_provider_.reset(); |
| 92 } | 92 } |
| 93 | 93 |
| 94 protected: | 94 protected: |
| 95 // Called when a signal is received. | 95 // Called when a signal is received. |
| 96 void OnSignalReceived(dbus::Signal* signal) { | 96 void OnSignalReceived(dbus::Signal* signal) { |
| 97 ASSERT_EQ(kReturnSignalInterface, signal->GetInterface()); | 97 ASSERT_EQ(kReturnSignalInterface, signal->GetInterface()); |
| 98 ASSERT_EQ(kReturnSignalName, signal->GetMember()); | 98 ASSERT_EQ(kReturnSignalName, signal->GetMember()); |
| 99 | 99 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 ASSERT_TRUE(response.get()); | 170 ASSERT_TRUE(response.get()); |
| 171 dbus::MessageReader reader(response.get()); | 171 dbus::MessageReader reader(response.get()); |
| 172 ASSERT_FALSE(reader.HasMoreData()); | 172 ASSERT_FALSE(reader.HasMoreData()); |
| 173 | 173 |
| 174 // Confirm that the signal is received successfully. | 174 // Confirm that the signal is received successfully. |
| 175 // The contents of the signal are checked in OnSignalReceived(). | 175 // The contents of the signal are checked in OnSignalReceived(). |
| 176 ASSERT_TRUE(signal_received_successfully_); | 176 ASSERT_TRUE(signal_received_successfully_); |
| 177 } | 177 } |
| 178 | 178 |
| 179 } // namespace chromeos | 179 } // namespace chromeos |
| OLD | NEW |