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

Unified Diff: components/arc/test/fake_arc_bridge_service.h

Issue 1413153007: arc-app-launcher: Minimal support for ARC app launcher. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merged FakeArcBridgeService, comments addressed. 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 side-by-side diff with in-line comments
Download patch
Index: components/arc/test/fake_arc_bridge_service.h
diff --git a/components/arc/test/fake_arc_bridge_service.h b/components/arc/test/fake_arc_bridge_service.h
new file mode 100644
index 0000000000000000000000000000000000000000..8d21aa1fb4084caa0eead8d1dfe67357bcc62211
--- /dev/null
+++ b/components/arc/test/fake_arc_bridge_service.h
@@ -0,0 +1,117 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_ARC_TEST_FAKE_ARC_BRIDGE_SERVICE_H_
+#define COMPONENTS_ARC_TEST_FAKE_ARC_BRIDGE_SERVICE_H_
+
+#include <string>
+#include <vector>
+
+#include "base/macros.h"
+#include "base/memory/scoped_vector.h"
+#include "components/arc/arc_bridge_service.h"
+
+namespace arc {
+
+class FakeArcBridgeService : public ArcBridgeService {
+ public:
+ class Request {
+ public:
+ Request(const std::string& package, const std::string& activity)
+ : package_(package),
+ activity_(activity) {
+ }
+
+ ~Request() {
+ }
+
+ const std::string& package() const { return package_; }
+
+ const std::string& activity() const { return activity_; }
+
+ bool IsForApp(const AppInfo& app_info) const {
+ return package_ == app_info.package && activity_ == app_info.activity;
+ }
+
+ private:
+ std::string package_;
+ std::string activity_;
+
+ 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
+ };
+
+ class IconRequest : public Request {
+ public:
+ IconRequest(const std::string& package,
+ const std::string& activity,
+ ScaleFactor scale_factor)
+ : Request(package, activity),
+ scale_factor_(scale_factor) {
+ }
+
+ ~IconRequest() {
+ }
+
+ int scale_factor() const { return scale_factor_; }
+
+ private:
+ int scale_factor_;
+
+ DISALLOW_COPY_AND_ASSIGN(IconRequest);
+ };
+
+ FakeArcBridgeService();
+ ~FakeArcBridgeService() override;
+
+ // arc::ArcBridgeService
+ void DetectAvailability() override;
+ void HandleStartup() override;
+ void Shutdown() override;
+ bool RegisterInputDevice(const std::string& name,
+ const std::string& device_type,
+ base::ScopedFD fd) override;
+ bool RefreshAppList() override;
+ bool LaunchApp(const std::string& package,
+ const std::string& activity) override;
+ bool RequestAppIcon(const std::string& package,
+ const std::string& activity,
+ ScaleFactor scale_factor) override;
+
+ int refresh_app_list_count() const { return refresh_app_list_count_; }
+
+ const ScopedVector<Request>& launch_requests() const {
+ return launch_requests_;
+ }
+
+ const ScopedVector<IconRequest>& icon_requests() const {
+ return icon_requests_;
+ }
+
+ void SetReady();
+
+ void SetStopped();
+
+ bool HasObserver(const Observer* observer);
+ bool HasAppObserver(const AppObserver* observer);
+
+ void SendRefreshAppList(const std::vector<AppInfo>& apps);
+
+ bool GenerateAndSendIcon(const AppInfo& app,
+ ScaleFactor scale_factor,
+ std::string* png_data);
+
+ private:
+ // Number of RefreshAppList calls.
+ int refresh_app_list_count_ = 0;
+ // Keeps information about launch requests.
+ ScopedVector<Request> launch_requests_;
+ // Keeps information about icon load requests.
+ ScopedVector<IconRequest> icon_requests_;
+
+ DISALLOW_COPY_AND_ASSIGN(FakeArcBridgeService);
+};
+
+} // namespace arc
+
+#endif // COMPONENTS_ARC_TEST_FAKE_ARC_BRIDGE_SERVICE_H_

Powered by Google App Engine
This is Rietveld 408576698