| 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/display/display_info.h" | 8 #include "ash/display/display_info.h" |
| 9 #include "ash/touch/touchscreen_util.h" | 9 #include "ash/touch/touchscreen_util.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 #include "ui/events/devices/input_device.h" | 11 #include "ui/events/devices/input_device.h" |
| 12 | 12 |
| 13 namespace ash { | 13 namespace ash { |
| 14 | 14 |
| 15 class TouchscreenUtilTest : public testing::Test { | 15 class TouchscreenUtilTest : public testing::Test { |
| 16 public: | 16 public: |
| 17 TouchscreenUtilTest() {} | 17 TouchscreenUtilTest() {} |
| 18 virtual ~TouchscreenUtilTest() {} | 18 ~TouchscreenUtilTest() override {} |
| 19 | 19 |
| 20 virtual void SetUp() override { | 20 void SetUp() override { |
| 21 // Internal display will always match to internal touchscreen. If internal | 21 // Internal display will always match to internal touchscreen. If internal |
| 22 // touchscreen can't be detected, it is then associated to a touch screen | 22 // touchscreen can't be detected, it is then associated to a touch screen |
| 23 // with matching size. | 23 // with matching size. |
| 24 { | 24 { |
| 25 DisplayInfo display(1, std::string(), false); | 25 DisplayInfo display(1, std::string(), false); |
| 26 DisplayMode mode(gfx::Size(1920, 1080), 60.0, false, true); | 26 DisplayMode mode(gfx::Size(1920, 1080), 60.0, false, true); |
| 27 mode.native = true; | 27 mode.native = true; |
| 28 std::vector<DisplayMode> modes(1, mode); | 28 std::vector<DisplayMode> modes(1, mode); |
| 29 display.SetDisplayModes(modes); | 29 display.SetDisplayModes(modes); |
| 30 displays_.push_back(display); | 30 displays_.push_back(display); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 49 { | 49 { |
| 50 DisplayInfo display(4, std::string(), false); | 50 DisplayInfo display(4, std::string(), false); |
| 51 DisplayMode mode(gfx::Size(1024, 768), 60.0, false, true); | 51 DisplayMode mode(gfx::Size(1024, 768), 60.0, false, true); |
| 52 mode.native = true; | 52 mode.native = true; |
| 53 std::vector<DisplayMode> modes(1, mode); | 53 std::vector<DisplayMode> modes(1, mode); |
| 54 display.SetDisplayModes(modes); | 54 display.SetDisplayModes(modes); |
| 55 displays_.push_back(display); | 55 displays_.push_back(display); |
| 56 } | 56 } |
| 57 } | 57 } |
| 58 | 58 |
| 59 virtual void TearDown() override { | 59 void TearDown() override { displays_.clear(); } |
| 60 displays_.clear(); | |
| 61 } | |
| 62 | 60 |
| 63 protected: | 61 protected: |
| 64 std::vector<DisplayInfo> displays_; | 62 std::vector<DisplayInfo> displays_; |
| 65 | 63 |
| 66 private: | 64 private: |
| 67 DISALLOW_COPY_AND_ASSIGN(TouchscreenUtilTest); | 65 DISALLOW_COPY_AND_ASSIGN(TouchscreenUtilTest); |
| 68 }; | 66 }; |
| 69 | 67 |
| 70 TEST_F(TouchscreenUtilTest, NoTouchscreens) { | 68 TEST_F(TouchscreenUtilTest, NoTouchscreens) { |
| 71 std::vector<ui::TouchscreenDevice> devices; | 69 std::vector<ui::TouchscreenDevice> devices; |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 AssociateTouchscreens(&displays_, devices); | 151 AssociateTouchscreens(&displays_, devices); |
| 154 | 152 |
| 155 // Internal touchscreen is always mapped to internal display. | 153 // Internal touchscreen is always mapped to internal display. |
| 156 EXPECT_EQ(2u, displays_[0].touch_device_id()); | 154 EXPECT_EQ(2u, displays_[0].touch_device_id()); |
| 157 EXPECT_EQ(1u, displays_[1].touch_device_id()); | 155 EXPECT_EQ(1u, displays_[1].touch_device_id()); |
| 158 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[2].touch_device_id()); | 156 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[2].touch_device_id()); |
| 159 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[3].touch_device_id()); | 157 EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[3].touch_device_id()); |
| 160 } | 158 } |
| 161 | 159 |
| 162 } // namespace ash | 160 } // namespace ash |
| OLD | NEW |