summaryrefslogtreecommitdiffstats
path: root/components
diff options
context:
space:
mode:
Diffstat (limited to 'components')
-rw-r--r--components/arc.gypi16
-rw-r--r--components/arc/BUILD.gn13
-rw-r--r--components/arc/test/fake_arc_bridge_service.cc145
-rw-r--r--components/arc/test/fake_arc_bridge_service.h119
-rw-r--r--components/test/data/arc/icon_100p.pngbin0 -> 2794 bytes
-rw-r--r--components/test/data/arc/icon_125p.pngbin0 -> 3952 bytes
-rw-r--r--components/test/data/arc/icon_133p.pngbin0 -> 4303 bytes
-rw-r--r--components/test/data/arc/icon_140p.pngbin0 -> 4499 bytes
-rw-r--r--components/test/data/arc/icon_150p.pngbin0 -> 4861 bytes
-rw-r--r--components/test/data/arc/icon_180p.pngbin0 -> 5573 bytes
-rw-r--r--components/test/data/arc/icon_200p.pngbin0 -> 5679 bytes
-rw-r--r--components/test/data/arc/icon_250p.pngbin0 -> 6221 bytes
-rw-r--r--components/test/data/arc/icon_300p.pngbin0 -> 3548 bytes
13 files changed, 293 insertions, 0 deletions
diff --git a/components/arc.gypi b/components/arc.gypi
index 7ad1264..7105b7b 100644
--- a/components/arc.gypi
+++ b/components/arc.gypi
@@ -32,5 +32,21 @@
'arc/common/arc_notification_types.cc',
],
},
+ {
+ # GN version: //components/arc_test_support
+ 'target_name': 'arc_test_support',
+ 'type': 'static_library',
+ 'include_dirs': [
+ '..',
+ ],
+ 'dependencies': [
+ '../base/base.gyp:base',
+ 'arc',
+ ],
+ 'sources': [
+ 'arc/test/fake_arc_bridge_service.cc',
+ 'arc/test/fake_arc_bridge_service.h',
+ ],
+ },
],
}
diff --git a/components/arc/BUILD.gn b/components/arc/BUILD.gn
index fe11655..6ab9270 100644
--- a/components/arc/BUILD.gn
+++ b/components/arc/BUILD.gn
@@ -20,6 +20,19 @@ static_library("arc") {
]
}
+static_library("arc_test_support") {
+ testonly = true
+ sources = [
+ "test/fake_arc_bridge_service.cc",
+ "test/fake_arc_bridge_service.h",
+ ]
+
+ deps = [
+ ":arc",
+ "//base",
+ ]
+}
+
source_set("unit_tests") {
testonly = true
sources = [
diff --git a/components/arc/test/fake_arc_bridge_service.cc b/components/arc/test/fake_arc_bridge_service.cc
new file mode 100644
index 0000000..ace3acf
--- /dev/null
+++ b/components/arc/test/fake_arc_bridge_service.cc
@@ -0,0 +1,145 @@
+// 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.
+
+#include "components/arc/test/fake_arc_bridge_service.h"
+
+#include "base/files/file_path.h"
+#include "base/files/file_util.h"
+#include "base/path_service.h"
+
+namespace arc {
+
+FakeArcBridgeService::FakeArcBridgeService() {
+}
+
+FakeArcBridgeService::~FakeArcBridgeService() {
+ if (state() != State::STOPPED) {
+ SetState(State::STOPPED);
+ }
+}
+
+void FakeArcBridgeService::DetectAvailability() {
+}
+
+void FakeArcBridgeService::HandleStartup() {
+}
+
+void FakeArcBridgeService::Shutdown() {
+}
+
+bool FakeArcBridgeService::RegisterInputDevice(const std::string& name,
+ const std::string& device_type,
+ base::ScopedFD fd) {
+ return true;
+}
+
+bool FakeArcBridgeService::SendNotificationEventToAndroid(
+ const std::string& key,
+ ArcNotificationEvent event) {
+ return true;
+}
+
+bool FakeArcBridgeService::RefreshAppList() {
+ ++refresh_app_list_count_;
+ return true;
+}
+
+bool FakeArcBridgeService::LaunchApp(const std::string& package,
+ const std::string& activity) {
+ launch_requests_.push_back(new Request(package, activity));
+ return true;
+}
+
+bool FakeArcBridgeService::RequestAppIcon(const std::string& package,
+ const std::string& activity,
+ ScaleFactor scale_factor) {
+ icon_requests_.push_back(new IconRequest(package, activity, scale_factor));
+ return true;
+}
+
+void FakeArcBridgeService::SetReady() {
+ SetState(State::READY);
+}
+
+void FakeArcBridgeService::SetStopped() {
+ SetState(State::STOPPED);
+}
+
+bool FakeArcBridgeService::HasObserver(const Observer* observer) {
+ return observer_list().HasObserver(observer);
+}
+
+bool FakeArcBridgeService::HasAppObserver(const AppObserver* observer) {
+ return app_observer_list().HasObserver(observer);
+}
+
+void FakeArcBridgeService::SendRefreshAppList(
+ const std::vector<AppInfo>& apps) {
+ FOR_EACH_OBSERVER(AppObserver, app_observer_list(), OnAppListRefreshed(apps));
+}
+
+bool FakeArcBridgeService::GenerateAndSendIcon(
+ const AppInfo& app,
+ ScaleFactor scale_factor,
+ std::string* png_data_as_string) {
+ CHECK(png_data_as_string != nullptr);
+ std::string icon_file_name;
+ switch(scale_factor) {
+ case SCALE_FACTOR_100P:
+ icon_file_name = "icon_100p.png";
+ break;
+ case SCALE_FACTOR_125P:
+ icon_file_name = "icon_125p.png";
+ break;
+ case SCALE_FACTOR_133P:
+ icon_file_name = "icon_133p.png";
+ break;
+ case SCALE_FACTOR_140P:
+ icon_file_name = "icon_140p.png";
+ break;
+ case SCALE_FACTOR_150P:
+ icon_file_name = "icon_150p.png";
+ break;
+ case SCALE_FACTOR_180P:
+ icon_file_name = "icon_180p.png";
+ break;
+ case SCALE_FACTOR_200P:
+ icon_file_name = "icon_200p.png";
+ break;
+ case SCALE_FACTOR_250P:
+ icon_file_name = "icon_250p.png";
+ break;
+ case SCALE_FACTOR_300P:
+ icon_file_name = "icon_300p.png";
+ break;
+ default:
+ NOTREACHED();
+ return false;
+ }
+
+ base::FilePath base_path;
+ CHECK(PathService::Get(base::DIR_SOURCE_ROOT, &base_path));
+ base::FilePath icon_file_path = base_path
+ .AppendASCII("components")
+ .AppendASCII("test")
+ .AppendASCII("data")
+ .AppendASCII("arc")
+ .AppendASCII(icon_file_name);
+ CHECK(base::PathExists(icon_file_path));
+ CHECK(base::ReadFileToString(icon_file_path, png_data_as_string));
+
+ std::vector<uint8_t> png_data(png_data_as_string->begin(),
+ png_data_as_string->end());
+
+ FOR_EACH_OBSERVER(AppObserver,
+ app_observer_list(),
+ OnAppIcon(app.package,
+ app.activity,
+ scale_factor,
+ png_data));
+
+ return true;
+}
+
+} // namespace arc
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 0000000..ef4e20d
--- /dev/null
+++ b/components/arc/test/fake_arc_bridge_service.h
@@ -0,0 +1,119 @@
+// 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);
+ };
+
+ 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;
+ bool SendNotificationEventToAndroid(const std::string& key,
+ ArcNotificationEvent event) 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_
diff --git a/components/test/data/arc/icon_100p.png b/components/test/data/arc/icon_100p.png
new file mode 100644
index 0000000..80a5d68
--- /dev/null
+++ b/components/test/data/arc/icon_100p.png
Binary files differ
diff --git a/components/test/data/arc/icon_125p.png b/components/test/data/arc/icon_125p.png
new file mode 100644
index 0000000..c9bae8e
--- /dev/null
+++ b/components/test/data/arc/icon_125p.png
Binary files differ
diff --git a/components/test/data/arc/icon_133p.png b/components/test/data/arc/icon_133p.png
new file mode 100644
index 0000000..565bbac
--- /dev/null
+++ b/components/test/data/arc/icon_133p.png
Binary files differ
diff --git a/components/test/data/arc/icon_140p.png b/components/test/data/arc/icon_140p.png
new file mode 100644
index 0000000..f85cae5
--- /dev/null
+++ b/components/test/data/arc/icon_140p.png
Binary files differ
diff --git a/components/test/data/arc/icon_150p.png b/components/test/data/arc/icon_150p.png
new file mode 100644
index 0000000..e3471fd
--- /dev/null
+++ b/components/test/data/arc/icon_150p.png
Binary files differ
diff --git a/components/test/data/arc/icon_180p.png b/components/test/data/arc/icon_180p.png
new file mode 100644
index 0000000..91c8dcb
--- /dev/null
+++ b/components/test/data/arc/icon_180p.png
Binary files differ
diff --git a/components/test/data/arc/icon_200p.png b/components/test/data/arc/icon_200p.png
new file mode 100644
index 0000000..be3aa10
--- /dev/null
+++ b/components/test/data/arc/icon_200p.png
Binary files differ
diff --git a/components/test/data/arc/icon_250p.png b/components/test/data/arc/icon_250p.png
new file mode 100644
index 0000000..4843664
--- /dev/null
+++ b/components/test/data/arc/icon_250p.png
Binary files differ
diff --git a/components/test/data/arc/icon_300p.png b/components/test/data/arc/icon_300p.png
new file mode 100644
index 0000000..d0afd96
--- /dev/null
+++ b/components/test/data/arc/icon_300p.png
Binary files differ