Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 #ifndef COMPONENTS_ARC_TEST_FAKE_ARC_BRIDGE_SERVICE_H_ | |
| 6 #define COMPONENTS_ARC_TEST_FAKE_ARC_BRIDGE_SERVICE_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 #include <vector> | |
| 10 | |
| 11 #include "base/macros.h" | |
| 12 #include "base/memory/scoped_vector.h" | |
| 13 #include "components/arc/arc_bridge_service.h" | |
| 14 | |
| 15 namespace arc { | |
| 16 | |
| 17 class FakeArcBridgeService : public ArcBridgeService { | |
| 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); | |
|
hidehiko
2015/12/03 13:08:39
(optional) Just a note.
IMHO, it's ok to make this
jochen (gone - plz use gerrit)
2015/12/03 13:12:46
then it needs to be a struct
khmel1
2015/12/03 14:12:42
Thanks for explanation. My concern was that that R
| |
| 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(); | |
| 65 ~FakeArcBridgeService() override; | |
| 66 | |
| 67 // arc::ArcBridgeService | |
| 68 void DetectAvailability() override; | |
| 69 void HandleStartup() 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 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 | |
| 81 int refresh_app_list_count() const { return refresh_app_list_count_; } | |
| 82 | |
| 83 const ScopedVector<Request>& launch_requests() const { | |
| 84 return launch_requests_; | |
| 85 } | |
| 86 | |
| 87 const ScopedVector<IconRequest>& icon_requests() const { | |
| 88 return icon_requests_; | |
| 89 } | |
| 90 | |
| 91 void SetReady(); | |
| 92 | |
| 93 void SetStopped(); | |
| 94 | |
| 95 bool HasObserver(const Observer* observer); | |
| 96 bool HasAppObserver(const AppObserver* observer); | |
| 97 | |
| 98 void SendRefreshAppList(const std::vector<AppInfo>& apps); | |
| 99 | |
| 100 bool GenerateAndSendIcon(const AppInfo& app, | |
| 101 ScaleFactor scale_factor, | |
| 102 std::string* png_data); | |
| 103 | |
| 104 private: | |
| 105 // Number of RefreshAppList calls. | |
| 106 int refresh_app_list_count_ = 0; | |
| 107 // Keeps information about launch requests. | |
| 108 ScopedVector<Request> launch_requests_; | |
| 109 // Keeps information about icon load requests. | |
| 110 ScopedVector<IconRequest> icon_requests_; | |
| 111 | |
| 112 DISALLOW_COPY_AND_ASSIGN(FakeArcBridgeService); | |
| 113 }; | |
| 114 | |
| 115 } // namespace arc | |
| 116 | |
| 117 #endif // COMPONENTS_ARC_TEST_FAKE_ARC_BRIDGE_SERVICE_H_ | |
| OLD | NEW |