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 <memory> |
| 6 |
5 #include "base/bind.h" | 7 #include "base/bind.h" |
6 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
7 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/ptr_util.h" |
8 #include "base/run_loop.h" | 11 #include "base/run_loop.h" |
9 #include "chromeos/dbus/dbus_thread_manager.h" | 12 #include "chromeos/dbus/dbus_thread_manager.h" |
10 #include "components/arc/arc_bridge_service_impl.h" | 13 #include "components/arc/arc_bridge_service_impl.h" |
11 #include "components/arc/test/fake_arc_bridge_bootstrap.h" | 14 #include "components/arc/test/fake_arc_bridge_bootstrap.h" |
12 #include "components/arc/test/fake_arc_bridge_instance.h" | 15 #include "components/arc/test/fake_arc_bridge_instance.h" |
13 #include "ipc/mojo/scoped_ipc_support.h" | 16 #include "ipc/mojo/scoped_ipc_support.h" |
14 #include "mojo/public/cpp/system/message_pipe.h" | 17 #include "mojo/public/cpp/system/message_pipe.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
16 | 19 |
17 namespace arc { | 20 namespace arc { |
(...skipping 16 matching lines...) Expand all Loading... |
34 | 37 |
35 default: | 38 default: |
36 break; | 39 break; |
37 } | 40 } |
38 } | 41 } |
39 | 42 |
40 bool ready() const { return ready_; } | 43 bool ready() const { return ready_; } |
41 ArcBridgeService::State state() const { return state_; } | 44 ArcBridgeService::State state() const { return state_; } |
42 | 45 |
43 protected: | 46 protected: |
44 scoped_ptr<ArcBridgeServiceImpl> service_; | 47 std::unique_ptr<ArcBridgeServiceImpl> service_; |
45 scoped_ptr<FakeArcBridgeInstance> instance_; | 48 std::unique_ptr<FakeArcBridgeInstance> instance_; |
46 | 49 |
47 private: | 50 private: |
48 void SetUp() override { | 51 void SetUp() override { |
49 chromeos::DBusThreadManager::Initialize(); | 52 chromeos::DBusThreadManager::Initialize(); |
50 | 53 |
51 ready_ = false; | 54 ready_ = false; |
52 state_ = ArcBridgeService::State::STOPPED; | 55 state_ = ArcBridgeService::State::STOPPED; |
53 | 56 |
54 instance_.reset(new FakeArcBridgeInstance()); | 57 instance_.reset(new FakeArcBridgeInstance()); |
55 service_.reset(new ArcBridgeServiceImpl( | 58 service_.reset(new ArcBridgeServiceImpl( |
56 make_scoped_ptr(new FakeArcBridgeBootstrap(instance_.get())))); | 59 base::WrapUnique(new FakeArcBridgeBootstrap(instance_.get())))); |
57 | 60 |
58 service_->AddObserver(this); | 61 service_->AddObserver(this); |
59 } | 62 } |
60 | 63 |
61 void TearDown() override { | 64 void TearDown() override { |
62 service_->RemoveObserver(this); | 65 service_->RemoveObserver(this); |
63 instance_.reset(); | 66 instance_.reset(); |
64 service_.reset(); | 67 service_.reset(); |
65 | 68 |
66 chromeos::DBusThreadManager::Shutdown(); | 69 chromeos::DBusThreadManager::Shutdown(); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 service_->OnChannelClosed(); | 131 service_->OnChannelClosed(); |
129 instance_->WaitForInitCall(); | 132 instance_->WaitForInitCall(); |
130 ASSERT_EQ(ArcBridgeService::State::READY, state()); | 133 ASSERT_EQ(ArcBridgeService::State::READY, state()); |
131 ASSERT_EQ(2, instance_->init_calls()); | 134 ASSERT_EQ(2, instance_->init_calls()); |
132 | 135 |
133 service_->Shutdown(); | 136 service_->Shutdown(); |
134 ASSERT_EQ(ArcBridgeService::State::STOPPED, state()); | 137 ASSERT_EQ(ArcBridgeService::State::STOPPED, state()); |
135 } | 138 } |
136 | 139 |
137 } // namespace arc | 140 } // namespace arc |
OLD | NEW |