OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/intent_helper/arc_intent_helper_bridge.h" | 5 #include "components/arc/intent_helper/arc_intent_helper_bridge.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "components/arc/arc_bridge_service.h" | 10 #include "components/arc/arc_bridge_service.h" |
| 11 #include "components/arc/arc_service_manager.h" |
11 #include "components/arc/common/intent_helper.mojom.h" | 12 #include "components/arc/common/intent_helper.mojom.h" |
12 #include "components/arc/intent_helper/activity_icon_loader.h" | 13 #include "components/arc/intent_helper/activity_icon_loader.h" |
13 #include "components/arc/intent_helper/local_activity_resolver.h" | 14 #include "components/arc/intent_helper/local_activity_resolver.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
15 | 16 |
16 namespace arc { | 17 namespace arc { |
17 | 18 |
18 namespace { | 19 namespace { |
19 | 20 |
20 class ArcIntentHelperTest : public testing::Test { | 21 class ArcIntentHelperTest : public testing::Test { |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 instance_->OnIntentFiltersUpdated(std::vector<IntentFilter>()); | 159 instance_->OnIntentFiltersUpdated(std::vector<IntentFilter>()); |
159 EXPECT_TRUE(observer->IsUpdated()); | 160 EXPECT_TRUE(observer->IsUpdated()); |
160 | 161 |
161 // Observer should not be called after it's removed. | 162 // Observer should not be called after it's removed. |
162 observer->Reset(); | 163 observer->Reset(); |
163 instance_->RemoveObserver(observer.get()); | 164 instance_->RemoveObserver(observer.get()); |
164 instance_->OnIntentFiltersUpdated(std::vector<IntentFilter>()); | 165 instance_->OnIntentFiltersUpdated(std::vector<IntentFilter>()); |
165 EXPECT_FALSE(observer->IsUpdated()); | 166 EXPECT_FALSE(observer->IsUpdated()); |
166 } | 167 } |
167 | 168 |
| 169 // Tests if the getter works as expected. |
| 170 TEST_F(ArcIntentHelperTest, TestGet) { |
| 171 // The getter should return null when nullptr is passed in. |
| 172 EXPECT_EQ(nullptr, ArcIntentHelperBridge::Get(nullptr)); |
| 173 |
| 174 // The getter should return null when the manager doesn't have an |
| 175 // ArcIntentHelperBridge instance. |
| 176 ArcServiceManager manager(nullptr); |
| 177 EXPECT_EQ(nullptr, ArcIntentHelperBridge::Get(&manager)); |
| 178 |
| 179 // Register the instance and retry. The getter should return non-null this |
| 180 // time. |
| 181 manager.AddService(std::move(instance_)); |
| 182 EXPECT_NE(nullptr, ArcIntentHelperBridge::Get(&manager)); |
| 183 } |
| 184 |
168 } // namespace arc | 185 } // namespace arc |
OLD | NEW |