OLD | NEW |
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" |
12 #include "components/arc/arc_bridge_service.h" | 13 #include "components/arc/arc_bridge_service.h" |
13 | 14 |
14 namespace arc { | 15 namespace arc { |
15 | 16 |
16 class FakeArcBridgeService : public ArcBridgeService { | 17 class FakeArcBridgeService : public ArcBridgeService { |
17 public: | 18 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 |
18 FakeArcBridgeService(); | 64 FakeArcBridgeService(); |
19 ~FakeArcBridgeService() override; | 65 ~FakeArcBridgeService() override; |
20 | 66 |
21 // arc::ArcBridgeService | 67 // arc::ArcBridgeService |
22 void DetectAvailability() override; | 68 void DetectAvailability() override; |
23 void HandleStartup() override; | 69 void HandleStartup() override; |
24 void Shutdown() override; | 70 void Shutdown() override; |
| 71 bool RegisterInputDevice(const std::string& name, |
| 72 const std::string& device_type, |
| 73 base::ScopedFD fd) override; |
| 74 bool SendBroadcast(const std::string& action, |
| 75 const std::string& package, |
| 76 const std::string& clazz, |
| 77 const base::DictionaryValue& extras) override; |
| 78 bool RefreshAppList() override; |
| 79 bool LaunchApp(const std::string& package, |
| 80 const std::string& activity) override; |
| 81 bool RequestAppIcon(const std::string& package, |
| 82 const std::string& activity, |
| 83 ScaleFactor scale_factor) override; |
| 84 bool SendNotificationEventToAndroid(const std::string& key, |
| 85 ArcNotificationEvent event) override; |
| 86 bool RequestProcessList() override; |
| 87 |
| 88 int refresh_app_list_count() const { return refresh_app_list_count_; } |
| 89 |
| 90 const ScopedVector<Request>& launch_requests() const { |
| 91 return launch_requests_; |
| 92 } |
| 93 |
| 94 const ScopedVector<IconRequest>& icon_requests() const { |
| 95 return icon_requests_; |
| 96 } |
25 | 97 |
26 void SetReady(); | 98 void SetReady(); |
27 | 99 |
28 void SetStopped(); | 100 void SetStopped(); |
29 | 101 |
30 bool HasObserver(const Observer* observer); | 102 bool HasObserver(const Observer* observer); |
| 103 bool HasAppObserver(const AppObserver* observer); |
| 104 |
| 105 void SendRefreshAppList(const std::vector<AppInfo>& apps); |
| 106 |
| 107 bool GenerateAndSendIcon(const AppInfo& app, |
| 108 ScaleFactor scale_factor, |
| 109 std::string* png_data); |
31 | 110 |
32 private: | 111 private: |
| 112 // Number of RefreshAppList calls. |
| 113 int refresh_app_list_count_ = 0; |
| 114 // Keeps information about launch requests. |
| 115 ScopedVector<Request> launch_requests_; |
| 116 // Keeps information about icon load requests. |
| 117 ScopedVector<IconRequest> icon_requests_; |
| 118 |
33 DISALLOW_COPY_AND_ASSIGN(FakeArcBridgeService); | 119 DISALLOW_COPY_AND_ASSIGN(FakeArcBridgeService); |
34 }; | 120 }; |
35 | 121 |
36 } // namespace arc | 122 } // namespace arc |
37 | 123 |
38 #endif // COMPONENTS_ARC_TEST_FAKE_ARC_BRIDGE_SERVICE_H_ | 124 #endif // COMPONENTS_ARC_TEST_FAKE_ARC_BRIDGE_SERVICE_H_ |
OLD | NEW |