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

Unified Diff: chrome/browser/ui/webui/chromeos/login/oobe_display_chooser_unittest.cc

Issue 2964823002: Remove confusing keyboard test & focus on input device (Closed)
Patch Set: Break out device check code Created 3 years, 5 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: chrome/browser/ui/webui/chromeos/login/oobe_display_chooser_unittest.cc
diff --git a/chrome/browser/ui/webui/chromeos/login/oobe_display_chooser_unittest.cc b/chrome/browser/ui/webui/chromeos/login/oobe_display_chooser_unittest.cc
index acf074ae225fd6af55f93ded65c3882bc3763420..be3f5b1118b9572f04c5c4b59a0a2ec6bdd0f558 100644
--- a/chrome/browser/ui/webui/chromeos/login/oobe_display_chooser_unittest.cc
+++ b/chrome/browser/ui/webui/chromeos/login/oobe_display_chooser_unittest.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/ui/webui/chromeos/login/oobe_display_chooser.h"
#include <memory>
+#include <vector>
#include "ash/display/display_configuration_controller.h"
#include "ash/shell.h"
@@ -13,9 +14,12 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/display/display.h"
#include "ui/display/display_observer.h"
+#include "ui/display/manager/chromeos/touchscreen_util.h"
#include "ui/display/manager/display_manager.h"
#include "ui/display/screen.h"
#include "ui/display/test/display_manager_test_api.h"
+#include "ui/events/devices/device_data_manager.h"
+#include "ui/events/devices/touchscreen_device.h"
namespace chromeos {
@@ -25,63 +29,92 @@ class OobeDisplayChooserTest : public ash::test::AshTestBase {
public:
OobeDisplayChooserTest() : ash::test::AshTestBase() {}
- void SetUp() override {
- ash::test::AshTestBase::SetUp();
- display_manager_test_api_.reset(
- new display::test::DisplayManagerTestApi(display_manager()));
- }
-
- void EnableTouch(int64_t id) {
- display_manager_test_api_->SetTouchSupport(
- id, display::Display::TouchSupport::TOUCH_SUPPORT_AVAILABLE);
+ int64_t GetPrimaryDisplay() {
+ return display::Screen::GetScreen()->GetPrimaryDisplay().id();
}
- void DisableTouch(int64_t id) {
- display_manager_test_api_->SetTouchSupport(
- id, display::Display::TouchSupport::TOUCH_SUPPORT_UNAVAILABLE);
- }
+ void UpdateTouchscreenDevices(const ui::TouchscreenDevice& touchscreen) {
+ std::vector<ui::TouchscreenDevice> vec;
jdufault 2017/07/06 18:19:35 nit: Use {} constructor, ie, std::vector<ui::Touc
Felix Ekblom 2017/07/06 19:37:09 Done.
+ vec.push_back(touchscreen);
- int64_t GetPrimaryDisplay() {
- return display::Screen::GetScreen()->GetPrimaryDisplay().id();
+ ui::DeviceHotplugEventObserver* manager =
+ ui::DeviceDataManager::GetInstance();
+ manager->OnTouchscreenDevicesUpdated(vec);
}
private:
- std::unique_ptr<display::test::DisplayManagerTestApi>
- display_manager_test_api_;
-
DISALLOW_COPY_AND_ASSIGN(OobeDisplayChooserTest);
};
} // namespace
TEST_F(OobeDisplayChooserTest, PreferTouchAsPrimary) {
- OobeDisplayChooser display_chooser;
+ // Setup 2 displays, second one is intended to be a touch display
+ std::vector<display::ManagedDisplayInfo> display_info;
+ display_info.push_back(
+ display::ManagedDisplayInfo::CreateFromSpecWithID("0+0-3000x2000", 1));
+ display_info.push_back(
+ display::ManagedDisplayInfo::CreateFromSpecWithID("3000+0-800x600", 2));
+ display_manager()->OnNativeDisplaysChanged(display_info);
+ base::RunLoop().RunUntilIdle();
- UpdateDisplay("3000x2000,800x600");
- display::DisplayIdList ids = display_manager()->GetCurrentDisplayIdList();
- DisableTouch(ids[0]);
- EnableTouch(ids[1]);
+ // Make sure the non-touch display is primary
+ ash::Shell::Get()->window_tree_host_manager()->SetPrimaryDisplayId(1);
- EXPECT_EQ(ids[0], GetPrimaryDisplay());
- display_chooser.TryToPlaceUiOnTouchDisplay();
+ // Setup corresponding TouchscreenDevice object
+ ui::TouchscreenDevice touchscreen =
+ ui::TouchscreenDevice(1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL,
+ "Touchscreen", gfx::Size(800, 600), 1);
+ touchscreen.vendor_id = 0x266e;
+ UpdateTouchscreenDevices(touchscreen);
base::RunLoop().RunUntilIdle();
- EXPECT_EQ(ids[1], GetPrimaryDisplay());
-}
+ // Associate touchscreen device with display
+ display_info[1].AddInputDevice(touchscreen.id);
+ display_info[1].set_touch_support(display::Display::TOUCH_SUPPORT_AVAILABLE);
+ display_manager()->OnNativeDisplaysChanged(display_info);
+ base::RunLoop().RunUntilIdle();
-TEST_F(OobeDisplayChooserTest, AddingSecondTouchDisplayShouldbeNOP) {
OobeDisplayChooser display_chooser;
+ EXPECT_EQ(1, GetPrimaryDisplay());
+ display_chooser.TryToPlaceUiOnTouchDisplay();
+ base::RunLoop().RunUntilIdle();
+ EXPECT_EQ(2, GetPrimaryDisplay());
+}
- UpdateDisplay("3000x2000,800x600");
- display::DisplayIdList ids = display_manager()->GetCurrentDisplayIdList();
- EnableTouch(ids[0]);
- EnableTouch(ids[1]);
+TEST_F(OobeDisplayChooserTest, DontSwitchFromTouch) {
+ // Setup 2 displays, second one is intended to be a touch display
+ std::vector<display::ManagedDisplayInfo> display_info;
+ display_info.push_back(
+ display::ManagedDisplayInfo::CreateFromSpecWithID("0+0-3000x2000", 1));
+ display_info.push_back(
+ display::ManagedDisplayInfo::CreateFromSpecWithID("3000+0-800x600", 2));
+ display_info[0].set_touch_support(display::Display::TOUCH_SUPPORT_AVAILABLE);
+ display_manager()->OnNativeDisplaysChanged(display_info);
+ base::RunLoop().RunUntilIdle();
- EXPECT_EQ(ids[0], GetPrimaryDisplay());
- display_chooser.TryToPlaceUiOnTouchDisplay();
+ // Make sure the non-touch display is primary
+ ash::Shell::Get()->window_tree_host_manager()->SetPrimaryDisplayId(1);
+
+ // Setup corresponding TouchscreenDevice object
+ ui::TouchscreenDevice touchscreen =
+ ui::TouchscreenDevice(1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL,
+ "Touchscreen", gfx::Size(800, 600), 1);
+ touchscreen.vendor_id = 0x266e;
+ UpdateTouchscreenDevices(touchscreen);
+ base::RunLoop().RunUntilIdle();
+
+ // Associate touchscreen device with display
+ display_info[1].AddInputDevice(touchscreen.id);
+ display_info[1].set_touch_support(display::Display::TOUCH_SUPPORT_AVAILABLE);
+ display_manager()->OnNativeDisplaysChanged(display_info);
base::RunLoop().RunUntilIdle();
- EXPECT_EQ(ids[0], GetPrimaryDisplay());
+ OobeDisplayChooser display_chooser;
+ EXPECT_EQ(1, GetPrimaryDisplay());
+ display_chooser.TryToPlaceUiOnTouchDisplay();
+ base::RunLoop().RunUntilIdle();
+ EXPECT_EQ(1, GetPrimaryDisplay());
}
} // namespace chromeos

Powered by Google App Engine
This is Rietveld 408576698