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

Side by Side Diff: components/arc/test/fake_arc_bridge_service.h

Issue 1523643002: arc-bridge: Move most methods to Mojo interfaces (Closed) Base URL: https://chromium.googlesource.com/a/chromium/src.git@master
Patch Set: Added explicit ordinals and fixed a potential race 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
OLDNEW
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 #ifndef COMPONENTS_ARC_TEST_FAKE_ARC_BRIDGE_SERVICE_H_ 5 #ifndef COMPONENTS_ARC_TEST_FAKE_ARC_BRIDGE_SERVICE_H_
6 #define COMPONENTS_ARC_TEST_FAKE_ARC_BRIDGE_SERVICE_H_ 6 #define COMPONENTS_ARC_TEST_FAKE_ARC_BRIDGE_SERVICE_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/scoped_vector.h"
13 #include "components/arc/arc_bridge_service.h" 12 #include "components/arc/arc_bridge_service.h"
14 13
15 namespace arc { 14 namespace arc {
16 15
17 class FakeArcBridgeService : public ArcBridgeService { 16 class FakeArcBridgeService : public ArcBridgeService {
18 public: 17 public:
19 class Request {
20 public:
21 Request(const std::string& package, const std::string& activity)
22 : package_(package),
23 activity_(activity) {
24 }
25
26 ~Request() {
27 }
28
29 const std::string& package() const { return package_; }
30
31 const std::string& activity() const { return activity_; }
32
33 bool IsForApp(const AppInfo& app_info) const {
34 return package_ == app_info.package && activity_ == app_info.activity;
35 }
36
37 private:
38 std::string package_;
39 std::string activity_;
40
41 DISALLOW_COPY_AND_ASSIGN(Request);
42 };
43
44 class IconRequest : public Request {
45 public:
46 IconRequest(const std::string& package,
47 const std::string& activity,
48 ScaleFactor scale_factor)
49 : Request(package, activity),
50 scale_factor_(scale_factor) {
51 }
52
53 ~IconRequest() {
54 }
55
56 int scale_factor() const { return scale_factor_; }
57
58 private:
59 int scale_factor_;
60
61 DISALLOW_COPY_AND_ASSIGN(IconRequest);
62 };
63
64 FakeArcBridgeService(); 18 FakeArcBridgeService();
65 ~FakeArcBridgeService() override; 19 ~FakeArcBridgeService() override;
66 20
21 // Mojo interface setters.
22 void SetAppInstance(AppInstancePtr instance_ptr);
23 void SetInputInstance(InputInstancePtr instance_ptr);
24 void SetNotificationsInstance(NotificationsInstancePtr instance_ptr);
25 void SetPowerInstance(PowerInstancePtr instance_ptr);
26 void SetProcessListInstance(ProcessListInstancePtr instance_ptr);
27
67 // arc::ArcBridgeService 28 // arc::ArcBridgeService
68 void DetectAvailability() override; 29 void DetectAvailability() override;
69 void HandleStartup() override; 30 void HandleStartup() override;
70 void Shutdown() override; 31 void Shutdown() override;
71 bool RegisterInputDevice(const std::string& name,
72 const std::string& device_type,
73 base::ScopedFD fd) override;
74 bool RefreshAppList() override;
75 bool LaunchApp(const std::string& package,
76 const std::string& activity) override;
77 bool RequestAppIcon(const std::string& package,
78 const std::string& activity,
79 ScaleFactor scale_factor) override;
80 bool SendNotificationEventToAndroid(const std::string& key,
81 ArcNotificationEvent event) override;
82
83 int refresh_app_list_count() const { return refresh_app_list_count_; }
84
85 const ScopedVector<Request>& launch_requests() const {
86 return launch_requests_;
87 }
88
89 const ScopedVector<IconRequest>& icon_requests() const {
90 return icon_requests_;
91 }
92 32
93 void SetReady(); 33 void SetReady();
94 34
95 void SetStopped(); 35 void SetStopped();
96 36
97 bool HasObserver(const Observer* observer); 37 bool HasObserver(const Observer* observer);
98 bool HasAppObserver(const AppObserver* observer);
99
100 void SendRefreshAppList(const std::vector<AppInfo>& apps);
101
102 bool GenerateAndSendIcon(const AppInfo& app,
103 ScaleFactor scale_factor,
104 std::string* png_data);
105 38
106 private: 39 private:
107 // Number of RefreshAppList calls.
108 int refresh_app_list_count_ = 0;
109 // Keeps information about launch requests.
110 ScopedVector<Request> launch_requests_;
111 // Keeps information about icon load requests.
112 ScopedVector<IconRequest> icon_requests_;
113
114 DISALLOW_COPY_AND_ASSIGN(FakeArcBridgeService); 40 DISALLOW_COPY_AND_ASSIGN(FakeArcBridgeService);
115 }; 41 };
116 42
117 } // namespace arc 43 } // namespace arc
118 44
119 #endif // COMPONENTS_ARC_TEST_FAKE_ARC_BRIDGE_SERVICE_H_ 45 #endif // COMPONENTS_ARC_TEST_FAKE_ARC_BRIDGE_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698