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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #include <stdint.h> 5 #include <stdint.h>
6 6
7 #include <set> 7 #include <set>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/debug/leak_annotations.h" 10 #include "base/debug/leak_annotations.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/stl_util.h" 12 #include "base/stl_util.h"
13 #include "base/strings/string_number_conversions.h" 13 #include "base/strings/string_number_conversions.h"
14 #include "base/threading/thread_task_runner_handle.h"
14 #include "build/build_config.h" 15 #include "build/build_config.h"
15 #include "extensions/browser/api/system_display/display_info_provider.h" 16 #include "extensions/browser/api/system_display/display_info_provider.h"
16 #include "extensions/browser/api/system_display/system_display_api.h" 17 #include "extensions/browser/api/system_display/system_display_api.h"
17 #include "extensions/browser/api_test_utils.h" 18 #include "extensions/browser/api_test_utils.h"
18 #include "extensions/common/api/system_display.h" 19 #include "extensions/common/api/system_display.h"
19 #include "extensions/shell/test/shell_apitest.h" 20 #include "extensions/shell/test/shell_apitest.h"
20 #include "extensions/test/result_catcher.h" 21 #include "extensions/test/result_catcher.h"
21 #include "ui/display/display.h" 22 #include "ui/display/display.h"
22 #include "ui/display/screen.h" 23 #include "ui/display/screen.h"
23 24
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 bool unified_desktop_enabled() const { return unified_desktop_enabled_; } 135 bool unified_desktop_enabled() const { return unified_desktop_enabled_; }
135 136
136 bool calibration_started(const std::string& id) const { 137 bool calibration_started(const std::string& id) const {
137 return base::ContainsKey(overscan_started_, id); 138 return base::ContainsKey(overscan_started_, id);
138 } 139 }
139 140
140 bool calibration_changed(const std::string& id) const { 141 bool calibration_changed(const std::string& id) const {
141 return base::ContainsKey(overscan_adjusted_, id); 142 return base::ContainsKey(overscan_adjusted_, id);
142 } 143 }
143 144
145 void SetTouchCalibrationWillSucceed(bool success) {
146 native_touch_calibration_success_ = success;
147 }
148
149 bool IsNativeTouchCalibrationActive(std::string* error) override {
150 return false;
151 }
152
153 bool ShowNativeTouchCalibration(
154 const std::string& id,
155 std::string* error,
156 const DisplayInfoProvider::TouchCalibrationCallback& callback) override {
157 base::ThreadTaskRunnerHandle::Get()->PostTask(
158 FROM_HERE, base::Bind(callback, native_touch_calibration_success_));
159 return true;
160 }
161
144 private: 162 private:
145 // Update the content of the |unit| obtained for |display| using 163 // Update the content of the |unit| obtained for |display| using
146 // platform specific method. 164 // platform specific method.
147 void UpdateDisplayUnitInfoForPlatform( 165 void UpdateDisplayUnitInfoForPlatform(
148 const display::Display& display, 166 const display::Display& display,
149 extensions::api::system_display::DisplayUnitInfo* unit) override { 167 extensions::api::system_display::DisplayUnitInfo* unit) override {
150 int64_t id = display.id(); 168 int64_t id = display.id();
151 unit->name = "DISPLAY NAME FOR " + base::Int64ToString(id); 169 unit->name = "DISPLAY NAME FOR " + base::Int64ToString(id);
152 if (id == 1) 170 if (id == 1)
153 unit->mirroring_source_id = "0"; 171 unit->mirroring_source_id = "0";
(...skipping 10 matching lines...) Expand all
164 unit->overscan.bottom = 80; 182 unit->overscan.bottom = 80;
165 } 183 }
166 } 184 }
167 185
168 std::unique_ptr<base::DictionaryValue> set_info_value_; 186 std::unique_ptr<base::DictionaryValue> set_info_value_;
169 std::string set_info_display_id_; 187 std::string set_info_display_id_;
170 bool unified_desktop_enabled_ = false; 188 bool unified_desktop_enabled_ = false;
171 std::set<std::string> overscan_started_; 189 std::set<std::string> overscan_started_;
172 std::set<std::string> overscan_adjusted_; 190 std::set<std::string> overscan_adjusted_;
173 191
192 bool native_touch_calibration_success_ = false;
193
174 DISALLOW_COPY_AND_ASSIGN(MockDisplayInfoProvider); 194 DISALLOW_COPY_AND_ASSIGN(MockDisplayInfoProvider);
175 }; 195 };
176 196
177 class SystemDisplayApiTest : public ShellApiTest { 197 class SystemDisplayApiTest : public ShellApiTest {
178 public: 198 public:
179 SystemDisplayApiTest() 199 SystemDisplayApiTest()
180 : provider_(new MockDisplayInfoProvider), screen_(new MockScreen) {} 200 : provider_(new MockDisplayInfoProvider), screen_(new MockScreen) {}
181 201
182 ~SystemDisplayApiTest() override {} 202 ~SystemDisplayApiTest() override {}
183 203
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 420
401 // Calibration was started by the app but not completed. 421 // Calibration was started by the app but not completed.
402 ASSERT_TRUE(provider_->calibration_started(id)); 422 ASSERT_TRUE(provider_->calibration_started(id));
403 423
404 // Unloading the app should complete the calibraiton (and hide the overlay). 424 // Unloading the app should complete the calibraiton (and hide the overlay).
405 UnloadApp(extension); 425 UnloadApp(extension);
406 ASSERT_FALSE(provider_->calibration_changed(id)); 426 ASSERT_FALSE(provider_->calibration_changed(id));
407 ASSERT_FALSE(provider_->calibration_started(id)); 427 ASSERT_FALSE(provider_->calibration_started(id));
408 } 428 }
409 429
430 IN_PROC_BROWSER_TEST_F(SystemDisplayApiTest, ShowNativeTouchCalibrationFail) {
431 const std::string id = "display0";
432 std::unique_ptr<base::DictionaryValue> test_extension_value(
433 api_test_utils::ParseDictionary(kTestManifestKiosk));
434 scoped_refptr<Extension> test_extension(
435 api_test_utils::CreateExtension(test_extension_value.get()));
436
437 scoped_refptr<SystemDisplayShowNativeTouchCalibrationFunction>
438 show_native_calibration(
439 new SystemDisplayShowNativeTouchCalibrationFunction());
440
441 show_native_calibration->set_has_callback(true);
442 show_native_calibration->set_extension(test_extension.get());
443
444 provider_->SetTouchCalibrationWillSucceed(false);
445
446 std::string result(api_test_utils::RunFunctionAndReturnError(
447 show_native_calibration.get(), "[\"" + id + "\"]", browser_context()));
448
449 EXPECT_EQ(
450 result,
451 SystemDisplayShowNativeTouchCalibrationFunction::kTouchCalibrationError);
452 }
453
454 IN_PROC_BROWSER_TEST_F(SystemDisplayApiTest, ShowNativeTouchCalibration) {
455 const std::string id = "display0";
456 std::unique_ptr<base::DictionaryValue> test_extension_value(
457 api_test_utils::ParseDictionary(kTestManifestKiosk));
458 scoped_refptr<Extension> test_extension(
459 api_test_utils::CreateExtension(test_extension_value.get()));
460
461 scoped_refptr<SystemDisplayShowNativeTouchCalibrationFunction>
462 show_native_calibration(
463 new SystemDisplayShowNativeTouchCalibrationFunction());
464
465 show_native_calibration->set_has_callback(true);
466 show_native_calibration->set_extension(test_extension.get());
467
468 provider_->SetTouchCalibrationWillSucceed(true);
469
470 std::unique_ptr<base::Value> result(
471 api_test_utils::RunFunctionAndReturnSingleResult(
472 show_native_calibration.get(), "[\"" + id + "\"]",
473 browser_context()));
474
475 bool callback_result;
476 ASSERT_TRUE(result->GetAsBoolean(&callback_result));
477 ASSERT_TRUE(callback_result);
478 }
479
410 #endif // !defined(OS_CHROMEOS) 480 #endif // !defined(OS_CHROMEOS)
411 481
412 } // namespace extensions 482 } // namespace extensions
OLDNEW
« 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