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 "components/arc/arc_bridge_service.h" | |
6 | |
7 #include "base/memory/ref_counted.h" | 5 #include "base/memory/ref_counted.h" |
8 #include "base/run_loop.h" | 6 #include "base/run_loop.h" |
9 #include "chromeos/dbus/dbus_thread_manager.h" | 7 #include "chromeos/dbus/dbus_thread_manager.h" |
| 8 #include "components/arc/arc_bridge_service_impl.h" |
10 #include "components/arc/common/arc_host_messages.h" | 9 #include "components/arc/common/arc_host_messages.h" |
11 #include "ipc/ipc_channel.h" | 10 #include "ipc/ipc_channel.h" |
12 #include "ipc/ipc_channel_proxy.h" | 11 #include "ipc/ipc_channel_proxy.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
14 | 13 |
15 namespace arc { | 14 namespace arc { |
16 | 15 |
17 namespace { | 16 namespace { |
18 | 17 |
19 // A fake sender that can connect to a specified IPC::ChannelHandle. | 18 // A fake sender that can connect to a specified IPC::ChannelHandle. |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 boot_phase_ = boot_phase; | 71 boot_phase_ = boot_phase; |
73 } | 72 } |
74 | 73 |
75 bool ready() const { return ready_; } | 74 bool ready() const { return ready_; } |
76 InstanceBootPhase boot_phase() const { return boot_phase_; } | 75 InstanceBootPhase boot_phase() const { return boot_phase_; } |
77 ArcBridgeService::State state() const { return state_; } | 76 ArcBridgeService::State state() const { return state_; } |
78 | 77 |
79 protected: | 78 protected: |
80 scoped_ptr<IPCSenderFake> fake_sender_; | 79 scoped_ptr<IPCSenderFake> fake_sender_; |
81 | 80 |
82 scoped_ptr<ArcBridgeService> service_; | 81 scoped_ptr<ArcBridgeServiceImpl> service_; |
83 | 82 |
84 private: | 83 private: |
85 void SetUp() override { | 84 void SetUp() override { |
86 chromeos::DBusThreadManager::Initialize(); | 85 chromeos::DBusThreadManager::Initialize(); |
87 | 86 |
88 ready_ = false; | 87 ready_ = false; |
89 boot_phase_ = InstanceBootPhase::NOT_RUNNING; | 88 boot_phase_ = InstanceBootPhase::NOT_RUNNING; |
90 | 89 |
91 ipc_thread_.reset(new base::Thread("IPC thread")); | 90 ipc_thread_.reset(new base::Thread("IPC thread")); |
92 ipc_thread_->StartWithOptions( | 91 ipc_thread_->StartWithOptions( |
93 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); | 92 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); |
94 service_.reset(new ArcBridgeService(ipc_thread_->task_runner(), | 93 service_.reset(new ArcBridgeServiceImpl(ipc_thread_->task_runner(), |
95 message_loop_.task_runner())); | 94 message_loop_.task_runner())); |
96 | 95 |
97 service_->AddObserver(this); | 96 service_->AddObserver(this); |
98 | 97 |
99 IPC::ChannelHandle handle(IPC::Channel::GenerateUniqueRandomChannelID()); | 98 IPC::ChannelHandle handle(IPC::Channel::GenerateUniqueRandomChannelID()); |
100 // Testing code does not do all the steps that are done by regular | 99 // Testing code does not do all the steps that are done by regular |
101 // connection. In particular, it does not need to create a directory for | 100 // connection. In particular, it does not need to create a directory for |
102 // the socket, so manually set the state to CONNECTING. | 101 // the socket, so manually set the state to CONNECTING. |
103 service_->SetState(ArcBridgeService::State::CONNECTING); | 102 service_->SetState(ArcBridgeService::State::CONNECTING); |
104 // Connect directly to the specified channel instead of going through | 103 // Connect directly to the specified channel instead of going through |
105 // D-Bus, since it is not available for tests. | 104 // D-Bus, since it is not available for tests. |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 ASSERT_TRUE(state() == ArcBridgeService::State::STOPPING || | 184 ASSERT_TRUE(state() == ArcBridgeService::State::STOPPING || |
186 state() == ArcBridgeService::State::STOPPED); | 185 state() == ArcBridgeService::State::STOPPED); |
187 | 186 |
188 base::RunLoop run_loop; | 187 base::RunLoop run_loop; |
189 run_loop.Run(); | 188 run_loop.Run(); |
190 | 189 |
191 ASSERT_EQ(ArcBridgeService::State::STOPPED, state()); | 190 ASSERT_EQ(ArcBridgeService::State::STOPPED, state()); |
192 } | 191 } |
193 | 192 |
194 } // namespace arc | 193 } // namespace arc |
OLD | NEW |