Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(370)

Side by Side Diff: chrome/browser/ui/app_list/arc/arc_app_test.cc

Issue 1756193008: Support uninstalling ARC app from Chrome launcher (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: unittest, mojo callback Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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::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 arc::AppInfo store_app;
khmel 2016/03/07 21:11:52 nit: Can we do it more gracefully? For example ge
victorhsieh0 2016/03/07 23:54:43 Done. We don't need that package_name.
31 store_app.name = "Store";
32 store_app.package_name = "com.android.vending";
33 store_app.activity = "com.android.vending.activity";
34 store_app.sticky = true;
35 fake_apps_.push_back(store_app);
36
30 // Make sure we have enough data for test. 37 // Make sure we have enough data for test.
31 for (int i = 0; i < 3; ++i) { 38 for (int i = 0; i < 3; ++i) {
32 arc::AppInfo app; 39 arc::AppInfo app;
33 app.name = base::StringPrintf("Fake App %d", i); 40 app.name = base::StringPrintf("Fake App %d", i);
34 app.package_name = base::StringPrintf("fake.app.%d", i); 41 app.package_name = base::StringPrintf("fake.app.%d", i);
35 app.activity = base::StringPrintf("fake.app.%d.activity", i); 42 app.activity = base::StringPrintf("fake.app.%d.activity", i);
43 app.sticky = false;
36 fake_apps_.push_back(app); 44 fake_apps_.push_back(app);
37 } 45 }
38 46
39 bridge_service_.reset(new arc::FakeArcBridgeService()); 47 bridge_service_.reset(new arc::FakeArcBridgeService());
40 app_instance_.reset( 48 app_instance_.reset(
41 new arc::FakeAppInstance(ArcAppListPrefs::Get(browser_context_))); 49 new arc::FakeAppInstance(ArcAppListPrefs::Get(browser_context_)));
42 arc::AppInstancePtr instance; 50 arc::AppInstancePtr instance;
43 app_instance_->Bind(mojo::GetProxy(&instance)); 51 app_instance_->Bind(mojo::GetProxy(&instance));
44 bridge_service_->OnAppInstanceReady(std::move(instance)); 52 bridge_service_->OnAppInstanceReady(std::move(instance));
45 app_instance_->WaitForOnAppInstanceReady(); 53 app_instance_->WaitForOnAppInstanceReady();
46 54
47 // Check initial conditions. 55 // Check initial conditions.
48 EXPECT_EQ(bridge_service_.get(), arc::ArcBridgeService::Get()); 56 EXPECT_EQ(bridge_service_.get(), arc::ArcBridgeService::Get());
49 EXPECT_TRUE(!arc::ArcBridgeService::Get()->available()); 57 EXPECT_TRUE(!arc::ArcBridgeService::Get()->available());
50 EXPECT_EQ(arc::ArcBridgeService::State::STOPPED, 58 EXPECT_EQ(arc::ArcBridgeService::State::STOPPED,
51 arc::ArcBridgeService::Get()->state()); 59 arc::ArcBridgeService::Get()->state());
52 60
53 // At this point we should have ArcAppListPrefs as observer of service. 61 // At this point we should have ArcAppListPrefs as observer of service.
54 EXPECT_TRUE(bridge_service_->HasObserver(ArcAppListPrefs::Get( 62 EXPECT_TRUE(bridge_service_->HasObserver(ArcAppListPrefs::Get(
55 browser_context_))); 63 browser_context_)));
56 } 64 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698