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

Unified Diff: extensions/browser/api/system_display/system_display_apitest.cc

Issue 2656433004: - Plumbs through native touch calibration from MD settings to display manager via the system dis… (Closed)
Patch Set: Created 3 years, 11 months 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: extensions/browser/api/system_display/system_display_apitest.cc
diff --git a/extensions/browser/api/system_display/system_display_apitest.cc b/extensions/browser/api/system_display/system_display_apitest.cc
index 5e3e33f2d69ef2b5c58be978324f98f60da11315..43e36950507e7a0ff2e5a68848913a94005c6f55 100644
--- a/extensions/browser/api/system_display/system_display_apitest.cc
+++ b/extensions/browser/api/system_display/system_display_apitest.cc
@@ -11,6 +11,7 @@
#include "base/macros.h"
#include "base/stl_util.h"
#include "base/strings/string_number_conversions.h"
+#include "base/threading/thread_task_runner_handle.h"
#include "build/build_config.h"
#include "extensions/browser/api/system_display/display_info_provider.h"
#include "extensions/browser/api/system_display/system_display_api.h"
@@ -141,6 +142,23 @@ class MockDisplayInfoProvider : public DisplayInfoProvider {
return base::ContainsKey(overscan_adjusted_, id);
}
+ void SetTouchCalibrationWillSucceed(bool success) {
+ native_touch_calibration_success_ = success;
+ }
+
+ bool IsNativeTouchCalibrationActive(std::string* error) override {
+ return false;
+ }
+
+ bool ShowNativeTouchCalibration(
+ const std::string& id,
+ std::string* error,
+ const DisplayInfoProvider::TouchCalibrationCallback& callback) override {
+ base::ThreadTaskRunnerHandle::Get()->PostTask(
+ FROM_HERE, base::Bind(callback, native_touch_calibration_success_));
+ return true;
+ }
+
private:
// Update the content of the |unit| obtained for |display| using
// platform specific method.
@@ -171,6 +189,8 @@ class MockDisplayInfoProvider : public DisplayInfoProvider {
std::set<std::string> overscan_started_;
std::set<std::string> overscan_adjusted_;
+ bool native_touch_calibration_success_ = false;
+
DISALLOW_COPY_AND_ASSIGN(MockDisplayInfoProvider);
};
@@ -407,6 +427,56 @@ IN_PROC_BROWSER_TEST_F(SystemDisplayApiTest, OverscanCalibrationAppNoComplete) {
ASSERT_FALSE(provider_->calibration_started(id));
}
+IN_PROC_BROWSER_TEST_F(SystemDisplayApiTest, ShowNativeTouchCalibrationFail) {
+ const std::string id = "display0";
+ std::unique_ptr<base::DictionaryValue> test_extension_value(
+ api_test_utils::ParseDictionary(kTestManifestKiosk));
+ scoped_refptr<Extension> test_extension(
+ api_test_utils::CreateExtension(test_extension_value.get()));
+
+ scoped_refptr<SystemDisplayShowNativeTouchCalibrationFunction>
+ show_native_calibration(
+ new SystemDisplayShowNativeTouchCalibrationFunction());
+
+ show_native_calibration->set_has_callback(true);
+ show_native_calibration->set_extension(test_extension.get());
+
+ provider_->SetTouchCalibrationWillSucceed(false);
+
+ std::string result(api_test_utils::RunFunctionAndReturnError(
+ show_native_calibration.get(), "[\"" + id + "\"]", browser_context()));
+
+ EXPECT_EQ(
+ result,
+ SystemDisplayShowNativeTouchCalibrationFunction::kTouchCalibrationError);
+}
+
+IN_PROC_BROWSER_TEST_F(SystemDisplayApiTest, ShowNativeTouchCalibration) {
+ const std::string id = "display0";
+ std::unique_ptr<base::DictionaryValue> test_extension_value(
+ api_test_utils::ParseDictionary(kTestManifestKiosk));
+ scoped_refptr<Extension> test_extension(
+ api_test_utils::CreateExtension(test_extension_value.get()));
+
+ scoped_refptr<SystemDisplayShowNativeTouchCalibrationFunction>
+ show_native_calibration(
+ new SystemDisplayShowNativeTouchCalibrationFunction());
+
+ show_native_calibration->set_has_callback(true);
+ show_native_calibration->set_extension(test_extension.get());
+
+ provider_->SetTouchCalibrationWillSucceed(true);
+
+ std::unique_ptr<base::Value> result(
+ api_test_utils::RunFunctionAndReturnSingleResult(
+ show_native_calibration.get(), "[\"" + id + "\"]",
+ browser_context()));
+
+ bool callback_result;
+ ASSERT_TRUE(result->GetAsBoolean(&callback_result));
+ ASSERT_TRUE(callback_result);
+}
+
#endif // !defined(OS_CHROMEOS)
} // namespace extensions
« no previous file with comments | « extensions/browser/api/system_display/system_display_api.cc ('k') | extensions/browser/extension_function_histogram_value.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698