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 "chrome/browser/ui/app_list/arc/arc_app_test.h" | 5 #include "chrome/browser/ui/app_list/arc/arc_app_test.h" |
6 | 6 |
7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
8 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" | 8 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" |
9 #include "components/arc/arc_bridge_service.h" | 9 #include "components/arc/arc_bridge_service.h" |
10 #include "components/arc/common/app.mojom.h" | 10 #include "components/arc/common/app.mojom.h" |
11 #include "components/arc/test/fake_app_instance.h" | 11 #include "components/arc/test/fake_app_instance.h" |
12 #include "components/arc/test/fake_arc_bridge_service.h" | 12 #include "components/arc/test/fake_arc_bridge_service.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
14 | 14 |
15 // static | 15 // static |
16 std::string ArcAppTest::GetAppId(const arc::AppInfo& app_info) { | 16 std::string ArcAppTest::GetAppId(const arc::mojom::AppInfo& app_info) { |
17 return ArcAppListPrefs::GetAppId(app_info.package_name, app_info.activity); | 17 return ArcAppListPrefs::GetAppId(app_info.package_name, app_info.activity); |
18 } | 18 } |
19 | 19 |
20 ArcAppTest::ArcAppTest() { | 20 ArcAppTest::ArcAppTest() { |
21 } | 21 } |
22 | 22 |
23 ArcAppTest::~ArcAppTest() { | 23 ArcAppTest::~ArcAppTest() { |
24 } | 24 } |
25 | 25 |
26 void ArcAppTest::SetUp(content::BrowserContext* browser_context) { | 26 void ArcAppTest::SetUp(content::BrowserContext* browser_context) { |
27 DCHECK(!browser_context_); | 27 DCHECK(!browser_context_); |
28 browser_context_ = browser_context; | 28 browser_context_ = browser_context; |
29 | 29 |
30 // Make sure we have enough data for test. | 30 // Make sure we have enough data for test. |
31 for (int i = 0; i < 3; ++i) { | 31 for (int i = 0; i < 3; ++i) { |
32 arc::AppInfo app; | 32 arc::mojom::AppInfo app; |
33 app.name = base::StringPrintf("Fake App %d", i); | 33 app.name = base::StringPrintf("Fake App %d", i); |
34 app.package_name = base::StringPrintf("fake.app.%d", i); | 34 app.package_name = base::StringPrintf("fake.app.%d", i); |
35 app.activity = base::StringPrintf("fake.app.%d.activity", i); | 35 app.activity = base::StringPrintf("fake.app.%d.activity", i); |
36 app.sticky = false; | 36 app.sticky = false; |
37 fake_apps_.push_back(app); | 37 fake_apps_.push_back(app); |
38 } | 38 } |
39 fake_apps_[0].sticky = true; | 39 fake_apps_[0].sticky = true; |
40 | 40 |
41 bridge_service_.reset(new arc::FakeArcBridgeService()); | 41 bridge_service_.reset(new arc::FakeArcBridgeService()); |
42 app_instance_.reset( | 42 app_instance_.reset( |
43 new arc::FakeAppInstance(ArcAppListPrefs::Get(browser_context_))); | 43 new arc::FakeAppInstance(ArcAppListPrefs::Get(browser_context_))); |
44 arc::AppInstancePtr instance; | 44 arc::mojom::AppInstancePtr instance; |
45 app_instance_->Bind(mojo::GetProxy(&instance)); | 45 app_instance_->Bind(mojo::GetProxy(&instance)); |
46 bridge_service_->OnAppInstanceReady(std::move(instance)); | 46 bridge_service_->OnAppInstanceReady(std::move(instance)); |
47 app_instance_->WaitForOnAppInstanceReady(); | 47 app_instance_->WaitForOnAppInstanceReady(); |
48 | 48 |
49 // Check initial conditions. | 49 // Check initial conditions. |
50 EXPECT_EQ(bridge_service_.get(), arc::ArcBridgeService::Get()); | 50 EXPECT_EQ(bridge_service_.get(), arc::ArcBridgeService::Get()); |
51 EXPECT_TRUE(!arc::ArcBridgeService::Get()->available()); | 51 EXPECT_TRUE(!arc::ArcBridgeService::Get()->available()); |
52 EXPECT_EQ(arc::ArcBridgeService::State::STOPPED, | 52 EXPECT_EQ(arc::ArcBridgeService::State::STOPPED, |
53 arc::ArcBridgeService::Get()->state()); | 53 arc::ArcBridgeService::Get()->state()); |
54 | 54 |
55 // At this point we should have ArcAppListPrefs as observer of service. | 55 // At this point we should have ArcAppListPrefs as observer of service. |
56 EXPECT_TRUE(bridge_service_->HasObserver(ArcAppListPrefs::Get( | 56 EXPECT_TRUE(bridge_service_->HasObserver(ArcAppListPrefs::Get( |
57 browser_context_))); | 57 browser_context_))); |
58 } | 58 } |
OLD | NEW |