Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/run_loop.h" | 6 #include "base/run_loop.h" |
| 7 #include "chromeos/dbus/dbus_thread_manager.h" | 7 #include "chromeos/dbus/dbus_thread_manager.h" |
| 8 #include "chromeos/dbus/fake_permission_broker_client.h" | 8 #include "chromeos/dbus/fake_permission_broker_client.h" |
| 9 #include "chromeos/network/firewall_hole.h" | 9 #include "chromeos/network/firewall_hole.h" |
| 10 #include "dbus/file_descriptor.h" | 10 #include "dbus/file_descriptor.h" |
| 11 #include "testing/gmock/include/gmock/gmock.h" | 11 #include "testing/gmock/include/gmock/gmock.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 13 | 13 |
| 14 using chromeos::DBusThreadManager; | 14 using chromeos::DBusThreadManager; |
| 15 using chromeos::FirewallHole; | 15 using chromeos::FirewallHole; |
| 16 using testing::_; | 16 using testing::_; |
| 17 | 17 |
| 18 namespace { | 18 namespace { |
| 19 | 19 |
| 20 ACTION_TEMPLATE(InvokeCallback, | 20 ACTION_TEMPLATE(InvokeCallback, |
| 21 HAS_1_TEMPLATE_PARAMS(int, k), | 21 HAS_1_TEMPLATE_PARAMS(int, k), |
| 22 AND_1_VALUE_PARAMS(p1)) { | 22 AND_1_VALUE_PARAMS(p1)) { |
| 23 ::std::tr1::get<k>(args).Run(p1); | 23 ::std::tr1::get<k>(args).Run(p1); |
| 24 } | 24 } |
| 25 | 25 |
| 26 class MockPermissionsBrokerClient : public chromeos::PermissionBrokerClient { | 26 class MockPermissionsBrokerClient |
| 27 : public chromeos::FakePermissionBrokerClient { | |
|
pneubeck (no reviews)
2015/04/07 07:57:38
nothing of that fake is actually used. If anything
Reilly Grant (use Gerrit)
2015/04/07 20:12:10
I've moved MockPermissionBrokerClient into its own
| |
| 27 public: | 28 public: |
| 28 MockPermissionsBrokerClient() {} | 29 MockPermissionsBrokerClient() {} |
| 29 ~MockPermissionsBrokerClient() override {} | 30 ~MockPermissionsBrokerClient() override {} |
| 30 | 31 |
| 31 MOCK_METHOD1(Init, void(dbus::Bus* bus)); | |
| 32 MOCK_METHOD3(RequestPathAccess, | |
| 33 void(const std::string& path, | |
| 34 int interface_id, | |
| 35 const ResultCallback& callback)); | |
| 36 MOCK_METHOD4(RequestTcpPortAccess, | 32 MOCK_METHOD4(RequestTcpPortAccess, |
| 37 void(uint16 port, | 33 void(uint16 port, |
| 38 const std::string& interface, | 34 const std::string& interface, |
| 39 const dbus::FileDescriptor& lifeline_fd, | 35 const dbus::FileDescriptor& lifeline_fd, |
| 40 const ResultCallback& callback)); | 36 const ResultCallback& callback)); |
| 41 MOCK_METHOD4(RequestUdpPortAccess, | 37 MOCK_METHOD4(RequestUdpPortAccess, |
| 42 void(uint16 port, | 38 void(uint16 port, |
| 43 const std::string& interface, | 39 const std::string& interface, |
| 44 const dbus::FileDescriptor& lifeline_fd, | 40 const dbus::FileDescriptor& lifeline_fd, |
| 45 const ResultCallback& callback)); | 41 const ResultCallback& callback)); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 126 TEST_F(FirewallHoleTest, DenyUdpPortAccess) { | 122 TEST_F(FirewallHoleTest, DenyUdpPortAccess) { |
| 127 EXPECT_CALL(*mock_permissions_broker_client_, | 123 EXPECT_CALL(*mock_permissions_broker_client_, |
| 128 RequestUdpPortAccess(1234, "foo0", _, _)) | 124 RequestUdpPortAccess(1234, "foo0", _, _)) |
| 129 .WillOnce(InvokeCallback<3>(false)); | 125 .WillOnce(InvokeCallback<3>(false)); |
| 130 | 126 |
| 131 FirewallHole::Open( | 127 FirewallHole::Open( |
| 132 FirewallHole::PortType::UDP, 1234, "foo0", | 128 FirewallHole::PortType::UDP, 1234, "foo0", |
| 133 base::Bind(&FirewallHoleTest::AssertOpenFailure, base::Unretained(this))); | 129 base::Bind(&FirewallHoleTest::AssertOpenFailure, base::Unretained(this))); |
| 134 run_loop_.Run(); | 130 run_loop_.Run(); |
| 135 } | 131 } |
| OLD | NEW |