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

Side by Side Diff: components/arc/test/fake_app_instance.cc

Issue 1523643002: arc-bridge: Move most methods to Mojo interfaces (Closed) Base URL: https://chromium.googlesource.com/a/chromium/src.git@master
Patch Set: Rebased to ToT Created 5 years 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
« no previous file with comments | « components/arc/test/fake_app_instance.h ('k') | components/arc/test/fake_arc_bridge_instance.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "components/arc/test/fake_app_instance.h"
6
7 #include <string>
8 #include <vector>
9
10 #include "base/files/file_path.h"
11 #include "base/files/file_util.h"
12 #include "base/path_service.h"
13 #include "mojo/common/common_type_converters.h"
14
15 namespace mojo {
16
17 template <>
18 struct TypeConverter<arc::AppInfoPtr, arc::AppInfo> {
19 static arc::AppInfoPtr Convert(const arc::AppInfo& app_info) {
20 return app_info.Clone();
21 }
22 };
23
24 } // namespace mojo
25
26 namespace arc {
27
28 FakeAppInstance::FakeAppInstance(AppHost* app_host)
29 : binding_(this), app_host_(app_host) {}
30 FakeAppInstance::~FakeAppInstance() {}
31
32 void FakeAppInstance::RefreshAppList() {
33 ++refresh_app_list_count_;
34 }
35
36 void FakeAppInstance::LaunchApp(const mojo::String& package,
37 const mojo::String& activity) {
38 launch_requests_.push_back(new Request(package, activity));
39 }
40
41 void FakeAppInstance::RequestAppIcon(const mojo::String& package,
42 const mojo::String& activity,
43 ScaleFactor scale_factor) {
44 icon_requests_.push_back(new IconRequest(package, activity, scale_factor));
45 }
46
47 void FakeAppInstance::SendRefreshAppList(const std::vector<AppInfo>& apps) {
48 app_host_->OnAppListRefreshed(mojo::Array<AppInfoPtr>::From(apps));
49 }
50
51 bool FakeAppInstance::GenerateAndSendIcon(const AppInfo& app,
52 ScaleFactor scale_factor,
53 std::string* png_data_as_string) {
54 CHECK(png_data_as_string != nullptr);
55 std::string icon_file_name;
56 switch (scale_factor) {
57 case SCALE_FACTOR_SCALE_FACTOR_100P:
58 icon_file_name = "icon_100p.png";
59 break;
60 case SCALE_FACTOR_SCALE_FACTOR_125P:
61 icon_file_name = "icon_125p.png";
62 break;
63 case SCALE_FACTOR_SCALE_FACTOR_133P:
64 icon_file_name = "icon_133p.png";
65 break;
66 case SCALE_FACTOR_SCALE_FACTOR_140P:
67 icon_file_name = "icon_140p.png";
68 break;
69 case SCALE_FACTOR_SCALE_FACTOR_150P:
70 icon_file_name = "icon_150p.png";
71 break;
72 case SCALE_FACTOR_SCALE_FACTOR_180P:
73 icon_file_name = "icon_180p.png";
74 break;
75 case SCALE_FACTOR_SCALE_FACTOR_200P:
76 icon_file_name = "icon_200p.png";
77 break;
78 case SCALE_FACTOR_SCALE_FACTOR_250P:
79 icon_file_name = "icon_250p.png";
80 break;
81 case SCALE_FACTOR_SCALE_FACTOR_300P:
82 icon_file_name = "icon_300p.png";
83 break;
84 default:
85 NOTREACHED();
86 return false;
87 }
88
89 base::FilePath base_path;
90 CHECK(PathService::Get(base::DIR_SOURCE_ROOT, &base_path));
91 base::FilePath icon_file_path = base_path.AppendASCII("components")
92 .AppendASCII("test")
93 .AppendASCII("data")
94 .AppendASCII("arc")
95 .AppendASCII(icon_file_name);
96 CHECK(base::PathExists(icon_file_path));
97 CHECK(base::ReadFileToString(icon_file_path, png_data_as_string));
98
99 app_host_->OnAppIcon(app.package, app.activity, scale_factor,
100 mojo::Array<uint8_t>::From(*png_data_as_string));
101
102 return true;
103 }
104
105 } // namespace arc
OLDNEW
« no previous file with comments | « components/arc/test/fake_app_instance.h ('k') | components/arc/test/fake_arc_bridge_instance.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698