| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <string> | 5 #include <string> |
| 6 #include <vector> | 6 #include <vector> |
| 7 | 7 |
| 8 #include "ash/common/display/display_info.h" | 8 #include "ash/common/display/display_info.h" |
| 9 #include "ash/test/ash_test_base.h" | 9 #include "ash/test/ash_test_base.h" |
| 10 #include "ash/test/display_manager_test_api.h" | 10 #include "ash/test/display_manager_test_api.h" |
| 11 #include "ash/touch/touchscreen_util.h" | 11 #include "ash/touch/touchscreen_util.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 13 #include "ui/events/devices/input_device.h" | 13 #include "ui/events/devices/input_device.h" |
| 14 | 14 |
| 15 namespace ash { | 15 namespace ash { |
| 16 | 16 |
| 17 class TouchscreenUtilTest : public test::AshTestBase { | 17 class TouchscreenUtilTest : public test::AshTestBase { |
| 18 public: | 18 public: |
| 19 TouchscreenUtilTest() {} | 19 TouchscreenUtilTest() {} |
| 20 ~TouchscreenUtilTest() override {} | 20 ~TouchscreenUtilTest() override {} |
| 21 | 21 |
| 22 void SetUp() override { | 22 void SetUp() override { |
| 23 test::AshTestBase::SetUp(); | 23 test::AshTestBase::SetUp(); |
| 24 // Internal display will always match to internal touchscreen. If internal | 24 // Internal display will always match to internal touchscreen. If internal |
| 25 // touchscreen can't be detected, it is then associated to a touch screen | 25 // touchscreen can't be detected, it is then associated to a touch screen |
| 26 // with matching size. | 26 // with matching size. |
| 27 { | 27 { |
| 28 DisplayInfo display(1, "1", false); | 28 DisplayInfo display(1, "1", false); |
| 29 DisplayMode mode(gfx::Size(1920, 1080), 60.0, false, true); | 29 scoped_refptr<DisplayMode> mode( |
| 30 mode.native = true; | 30 new DisplayMode(gfx::Size(1920, 1080), 60.0, |
| 31 std::vector<DisplayMode> modes(1, mode); | 31 /* interlaced */ false, |
| 32 /* native */ true, |
| 33 /* ui_scale */ 1.0, |
| 34 /* device_scale_factor */ 1.0)); |
| 35 DisplayInfo::DisplayModeList modes(1, mode); |
| 32 display.SetDisplayModes(modes); | 36 display.SetDisplayModes(modes); |
| 33 displays_.push_back(display); | 37 displays_.push_back(display); |
| 34 } | 38 } |
| 35 | 39 |
| 36 { | 40 { |
| 37 DisplayInfo display(2, "2", false); | 41 DisplayInfo display(2, "2", false); |
| 38 DisplayMode mode(gfx::Size(800, 600), 60.0, false, true); | 42 |
| 39 mode.native = true; | 43 scoped_refptr<DisplayMode> mode( |
| 40 std::vector<DisplayMode> modes(1, mode); | 44 new DisplayMode(gfx::Size(800, 600), 60.0, /* interlaced */ false, |
| 45 /*native */ true, /* ui_scale */ 1.0, |
| 46 /* device_scale_factor */ 1.0)); |
| 47 DisplayInfo::DisplayModeList modes(1, mode); |
| 41 display.SetDisplayModes(modes); | 48 display.SetDisplayModes(modes); |
| 42 displays_.push_back(display); | 49 displays_.push_back(display); |
| 43 } | 50 } |
| 44 | 51 |
| 45 // Display without native mode. Must not be matched to any touch screen. | 52 // Display without native mode. Must not be matched to any touch screen. |
| 46 { | 53 { |
| 47 DisplayInfo display(3, "3", false); | 54 DisplayInfo display(3, "3", false); |
| 48 displays_.push_back(display); | 55 displays_.push_back(display); |
| 49 } | 56 } |
| 50 | 57 |
| 51 { | 58 { |
| 52 DisplayInfo display(4, "4", false); | 59 DisplayInfo display(4, "4", false); |
| 53 DisplayMode mode(gfx::Size(1024, 768), 60.0, false, true); | 60 |
| 54 mode.native = true; | 61 scoped_refptr<DisplayMode> mode( |
| 55 std::vector<DisplayMode> modes(1, mode); | 62 new DisplayMode(gfx::Size(1024, 768), 60.0, /* interlaced */ false, |
| 63 /*native */ true, /* ui_scale */ 1.0, |
| 64 /* device_scale_factor */ 1.0)); |
| 65 DisplayInfo::DisplayModeList modes(1, mode); |
| 56 display.SetDisplayModes(modes); | 66 display.SetDisplayModes(modes); |
| 57 displays_.push_back(display); | 67 displays_.push_back(display); |
| 58 } | 68 } |
| 59 } | 69 } |
| 60 | 70 |
| 61 void TearDown() override { | 71 void TearDown() override { |
| 62 displays_.clear(); | 72 displays_.clear(); |
| 63 test::AshTestBase::TearDown(); | 73 test::AshTestBase::TearDown(); |
| 64 } | 74 } |
| 65 | 75 |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 AssociateTouchscreens(&displays_, devices); | 267 AssociateTouchscreens(&displays_, devices); |
| 258 | 268 |
| 259 EXPECT_EQ(1u, displays_[0].input_devices().size()); | 269 EXPECT_EQ(1u, displays_[0].input_devices().size()); |
| 260 EXPECT_EQ(1, displays_[0].input_devices()[0]); | 270 EXPECT_EQ(1, displays_[0].input_devices()[0]); |
| 261 EXPECT_EQ(0u, displays_[1].input_devices().size()); | 271 EXPECT_EQ(0u, displays_[1].input_devices().size()); |
| 262 EXPECT_EQ(0u, displays_[2].input_devices().size()); | 272 EXPECT_EQ(0u, displays_[2].input_devices().size()); |
| 263 EXPECT_EQ(0u, displays_[3].input_devices().size()); | 273 EXPECT_EQ(0u, displays_[3].input_devices().size()); |
| 264 } | 274 } |
| 265 | 275 |
| 266 } // namespace ash | 276 } // namespace ash |
| OLD | NEW |