1c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// Copyright (c) 2013 The Chromium Authors. All rights reserved.
2c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
3c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// found in the LICENSE file.
4c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
5c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "ash/touch/touch_observer_hud.h"
6c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
7c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "ash/ash_switches.h"
8c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "ash/display/display_manager.h"
9c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "ash/root_window_controller.h"
105d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "ash/screen_util.h"
11eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#include "ash/shell.h"
12c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "ash/test/ash_test_base.h"
13c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "ash/test/display_manager_test_api.h"
14eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#include "ash/touch/touch_hud_debug.h"
151e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#include "ash/touch/touch_hud_projection.h"
16c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "base/command_line.h"
17c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "base/format_macros.h"
18868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "base/strings/stringprintf.h"
197dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch#include "ui/aura/window.h"
20cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#include "ui/views/widget/widget.h"
21c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
22c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)namespace ash {
23c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
241e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)class TouchHudTestBase : public test::AshTestBase {
25c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) public:
261e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  TouchHudTestBase() {}
271e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  virtual ~TouchHudTestBase() {}
28c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
29c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  virtual void SetUp() OVERRIDE {
30c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    test::AshTestBase::SetUp();
31c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
32c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    // Initialize display infos. They should be initialized after Ash
33c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    // environment is set up, i.e., after test::AshTestBase::SetUp().
34c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    internal_display_id_ = test::DisplayManagerTestApi(GetDisplayManager()).
35c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)        SetFirstDisplayAsInternalDisplay();
36c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    external_display_id_ = 10;
37c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    mirrored_display_id_ = 11;
38c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
39c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    internal_display_info_ =
40c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)        CreateDisplayInfo(internal_display_id_, gfx::Rect(0, 0, 500, 500));
41c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    external_display_info_ =
42c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)        CreateDisplayInfo(external_display_id_, gfx::Rect(1, 1, 100, 100));
43c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    mirrored_display_info_ =
44c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)        CreateDisplayInfo(mirrored_display_id_, gfx::Rect(0, 0, 100, 100));
45c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  }
46c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
47ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch  gfx::Display GetPrimaryDisplay() {
48ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch    return Shell::GetScreen()->GetPrimaryDisplay();
49c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  }
50c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
51c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  const gfx::Display& GetSecondaryDisplay() {
525d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    return ScreenUtil::GetSecondaryDisplay();
53c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  }
54c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
55c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  void SetupSingleDisplay() {
56c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    display_info_list_.clear();
57c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    display_info_list_.push_back(internal_display_info_);
58c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    GetDisplayManager()->OnNativeDisplaysChanged(display_info_list_);
59c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  }
60c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
61c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  void SetupDualDisplays() {
62c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    display_info_list_.clear();
63c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    display_info_list_.push_back(internal_display_info_);
64c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    display_info_list_.push_back(external_display_info_);
65c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    GetDisplayManager()->OnNativeDisplaysChanged(display_info_list_);
66c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  }
67c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
68c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  void SetInternalAsPrimary() {
69c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    const gfx::Display& internal_display =
70c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)        GetDisplayManager()->GetDisplayForId(internal_display_id_);
71c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    GetDisplayController()->SetPrimaryDisplay(internal_display);
72c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  }
73c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
74c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  void SetExternalAsPrimary() {
75c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    const gfx::Display& external_display =
76c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)        GetDisplayManager()->GetDisplayForId(external_display_id_);
77c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    GetDisplayController()->SetPrimaryDisplay(external_display);
78c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  }
79c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
80c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  void MirrorDisplays() {
81c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    DCHECK_EQ(2U, display_info_list_.size());
82c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    DCHECK_EQ(internal_display_id_, display_info_list_[0].id());
83c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    DCHECK_EQ(external_display_id_, display_info_list_[1].id());
84c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    display_info_list_[1] = mirrored_display_info_;
85c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    GetDisplayManager()->OnNativeDisplaysChanged(display_info_list_);
86c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  }
87c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
88c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  void UnmirrorDisplays() {
89c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    DCHECK_EQ(2U, display_info_list_.size());
90c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    DCHECK_EQ(internal_display_id_, display_info_list_[0].id());
91c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    DCHECK_EQ(mirrored_display_id_, display_info_list_[1].id());
92c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    display_info_list_[1] = external_display_info_;
93c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    GetDisplayManager()->OnNativeDisplaysChanged(display_info_list_);
94c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  }
95c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
96c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  void RemoveInternalDisplay() {
97c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    DCHECK_LT(0U, display_info_list_.size());
98c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    DCHECK_EQ(internal_display_id_, display_info_list_[0].id());
99c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    display_info_list_.erase(display_info_list_.begin());
100c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    GetDisplayManager()->OnNativeDisplaysChanged(display_info_list_);
101c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  }
102c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
103c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  void RemoveExternalDisplay() {
104c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    DCHECK_EQ(2U, display_info_list_.size());
105c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    display_info_list_.pop_back();
106c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    GetDisplayManager()->OnNativeDisplaysChanged(display_info_list_);
107c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  }
108c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
109c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  void AddInternalDisplay() {
110c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    DCHECK_EQ(0U, display_info_list_.size());
111c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    display_info_list_.push_back(internal_display_info_);
112c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    GetDisplayManager()->OnNativeDisplaysChanged(display_info_list_);
113c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  }
114c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
115c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  void AddExternalDisplay() {
116c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    DCHECK_EQ(1U, display_info_list_.size());
117c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    display_info_list_.push_back(external_display_info_);
118c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    GetDisplayManager()->OnNativeDisplaysChanged(display_info_list_);
119c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  }
120c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
121c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  int64 internal_display_id() const {
122c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    return internal_display_id_;
123c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  }
124c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
125c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  int64 external_display_id() const {
126c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    return external_display_id_;
127c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  }
128c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
1291e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) protected:
130c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  DisplayManager* GetDisplayManager() {
131c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    return Shell::GetInstance()->display_manager();
132c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  }
133c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
134c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  DisplayController* GetDisplayController() {
135c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    return Shell::GetInstance()->display_controller();
136c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  }
137c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
138c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  const gfx::Display& GetInternalDisplay() {
139c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    return GetDisplayManager()->GetDisplayForId(internal_display_id_);
140c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  }
141c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
142c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  const gfx::Display& GetExternalDisplay() {
143c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    return GetDisplayManager()->GetDisplayForId(external_display_id_);
144c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  }
145c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
1461e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  aura::Window* GetInternalRootWindow() {
147c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    return GetDisplayController()->GetRootWindowForDisplayId(
148c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)        internal_display_id_);
149c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  }
150c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
1511e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  aura::Window* GetExternalRootWindow() {
152c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    return GetDisplayController()->GetRootWindowForDisplayId(
153c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)        external_display_id_);
154c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  }
155c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
1561e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  aura::Window* GetPrimaryRootWindow() {
157c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    const gfx::Display& display = GetPrimaryDisplay();
158c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    return GetDisplayController()->GetRootWindowForDisplayId(display.id());
159c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  }
160c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
1611e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  aura::Window* GetSecondaryRootWindow() {
162c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    const gfx::Display& display = GetSecondaryDisplay();
163c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    return GetDisplayController()->GetRootWindowForDisplayId(display.id());
164c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  }
165c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
166c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch  RootWindowController* GetInternalRootController() {
1671e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)    aura::Window* root = GetInternalRootWindow();
168c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    return GetRootWindowController(root);
169c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  }
170c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
171c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch  RootWindowController* GetExternalRootController() {
1721e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)    aura::Window* root = GetExternalRootWindow();
173c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    return GetRootWindowController(root);
174c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  }
175c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
176c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch  RootWindowController* GetPrimaryRootController() {
1771e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)    aura::Window* root = GetPrimaryRootWindow();
178c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    return GetRootWindowController(root);
179c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  }
180c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
181c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch  RootWindowController* GetSecondaryRootController() {
1821e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)    aura::Window* root = GetSecondaryRootWindow();
183c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    return GetRootWindowController(root);
184c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  }
185c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
1861e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  DisplayInfo CreateDisplayInfo(int64 id, const gfx::Rect& bounds) {
1871e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)    DisplayInfo info(id, base::StringPrintf("x-%" PRId64, id), false);
1881e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)    info.SetBounds(bounds);
1891e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)    return info;
1901e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  }
1911e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
192c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch  aura::Window* GetRootWindowForTouchHud(TouchObserverHUD* hud) {
1931e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)    return hud->root_window_;
1941e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  }
1951e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
196c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch  views::Widget* GetWidgetForTouchHud(TouchObserverHUD* hud) {
1971e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)    return hud->widget_;
1981e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  }
1991e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
2001e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  int64 internal_display_id_;
2011e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  int64 external_display_id_;
2021e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  int64 mirrored_display_id_;
2031e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  DisplayInfo internal_display_info_;
2041e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  DisplayInfo external_display_info_;
2051e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  DisplayInfo mirrored_display_info_;
2061e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
2071e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  std::vector<DisplayInfo> display_info_list_;
2081e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
2091e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  DISALLOW_COPY_AND_ASSIGN(TouchHudTestBase);
2101e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)};
2111e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
2121e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)class TouchHudDebugTest : public TouchHudTestBase {
2131e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) public:
2141e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  TouchHudDebugTest() {}
2151e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  virtual ~TouchHudDebugTest() {}
2161e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
2171e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  virtual void SetUp() OVERRIDE {
2181e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)    // Add ash-touch-hud flag to enable debug touch HUD. This flag should be set
2191e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)    // before Ash environment is set up, i.e., before TouchHudTestBase::SetUp().
2201e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)    CommandLine::ForCurrentProcess()->AppendSwitch(
2211e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)        ash::switches::kAshTouchHud);
2221e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
2231e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)    TouchHudTestBase::SetUp();
2241e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  }
2251e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
2261e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  void CheckInternalDisplay() {
227c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch    EXPECT_NE(static_cast<TouchObserverHUD*>(NULL), GetInternalTouchHudDebug());
2281e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)    EXPECT_EQ(internal_display_id(), GetInternalTouchHudDebug()->display_id());
2291e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)    EXPECT_EQ(GetInternalRootWindow(),
2301e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)              GetRootWindowForTouchHud(GetInternalTouchHudDebug()));
2311e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)    EXPECT_EQ(GetInternalRootWindow(),
2321e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)              GetWidgetForTouchHud(GetInternalTouchHudDebug())->
2331e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)                  GetNativeView()->GetRootWindow());
2341e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)    EXPECT_EQ(GetInternalDisplay().size(),
2351e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)              GetWidgetForTouchHud(GetInternalTouchHudDebug())->
2361e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)                  GetWindowBoundsInScreen().size());
2371e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  }
2381e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
2391e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  void CheckExternalDisplay() {
240c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch    EXPECT_NE(static_cast<TouchHudDebug*>(NULL), GetExternalTouchHudDebug());
2411e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)    EXPECT_EQ(external_display_id(), GetExternalTouchHudDebug()->display_id());
2421e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)    EXPECT_EQ(GetExternalRootWindow(),
2431e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)              GetRootWindowForTouchHud(GetExternalTouchHudDebug()));
2441e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)    EXPECT_EQ(GetExternalRootWindow(),
2451e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)              GetWidgetForTouchHud(GetExternalTouchHudDebug())->
2461e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)                  GetNativeView()->GetRootWindow());
2471e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)    EXPECT_EQ(GetExternalDisplay().size(),
2481e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)              GetWidgetForTouchHud(GetExternalTouchHudDebug())->
2491e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)                  GetWindowBoundsInScreen().size());
2501e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  }
2511e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
2521e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) private:
253c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch  TouchHudDebug* GetInternalTouchHudDebug() {
254eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch    return GetInternalRootController()->touch_hud_debug();
255c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  }
256c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
257c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch  TouchHudDebug* GetExternalTouchHudDebug() {
258eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch    return GetExternalRootController()->touch_hud_debug();
259c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  }
260c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
261c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch  TouchHudDebug* GetPrimaryTouchHudDebug() {
262eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch    return GetPrimaryRootController()->touch_hud_debug();
263c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  }
264c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
265c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch  TouchHudDebug* GetSecondaryTouchHudDebug() {
266eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch    return GetSecondaryRootController()->touch_hud_debug();
267c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  }
268c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
2691e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  DISALLOW_COPY_AND_ASSIGN(TouchHudDebugTest);
2701e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)};
2711e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
2721e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)class TouchHudProjectionTest : public TouchHudTestBase {
2731e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) public:
2741e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  TouchHudProjectionTest() {}
2751e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  virtual ~TouchHudProjectionTest() {}
2761e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
2771e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  void EnableTouchHudProjection() {
2781e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)    Shell::GetInstance()->SetTouchHudProjectionEnabled(true);
279c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  }
280c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
2811e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  void DisableTouchHudProjection() {
2821e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)    Shell::GetInstance()->SetTouchHudProjectionEnabled(false);
2831e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  }
284c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
285c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch  TouchHudProjection* GetInternalTouchHudProjection() {
2861e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)    return GetInternalRootController()->touch_hud_projection();
2871e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  }
288c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
2891e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  int GetInternalTouchPointsCount() {
2901e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)    return GetInternalTouchHudProjection()->points_.size();
2911e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  }
2921e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
2931e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  void SendTouchEventToInternalHud(ui::EventType type,
2941e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)                                   const gfx::Point& location,
2951e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)                                   int touch_id) {
2961e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)    ui::TouchEvent event(type, location, touch_id, event_time);
2971e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)    GetInternalTouchHudProjection()->OnTouchEvent(&event);
2981e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
2991e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)    // Advance time for next event.
3001e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)    event_time += base::TimeDelta::FromMilliseconds(100);
3011e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  }
3021e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
3031e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) private:
3041e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  base::TimeDelta event_time;
3051e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
3061e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  DISALLOW_COPY_AND_ASSIGN(TouchHudProjectionTest);
307c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)};
308c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
3091e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// Checks if debug touch HUD is correctly initialized for a single display.
3101e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)TEST_F(TouchHudDebugTest, SingleDisplay) {
3111e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  // Setup a single display setting.
3121e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  SetupSingleDisplay();
3131e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
3141e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  // Check if touch HUD is set correctly and associated with appropriate
3151e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  // display.
3161e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  CheckInternalDisplay();
3171e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)}
3181e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
3191e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// Checks if debug touch HUDs are correctly initialized for two displays.
3201e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)TEST_F(TouchHudDebugTest, DualDisplays) {
3217d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)  if (!SupportsMultipleDisplays())
3227d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)    return;
3237d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)
324c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // Setup a dual display setting.
325c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  SetupDualDisplays();
326c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
327c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // Check if touch HUDs are set correctly and associated with appropriate
328c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // displays.
329c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  CheckInternalDisplay();
330c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  CheckExternalDisplay();
331c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)}
332c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
3331e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// Checks if debug touch HUDs are correctly handled when primary display is
3341e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// changed.
3351e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)TEST_F(TouchHudDebugTest, SwapPrimaryDisplay) {
3367d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)  if (!SupportsMultipleDisplays())
3377d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)    return;
3387d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)
339c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // Setup a dual display setting.
340c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  SetupDualDisplays();
341c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
342c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // Set the primary display to the external one.
343c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  SetExternalAsPrimary();
344c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
345c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // Check if displays' touch HUDs are not swapped as root windows are.
346c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  EXPECT_EQ(external_display_id(), GetPrimaryDisplay().id());
347c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  EXPECT_EQ(internal_display_id(), GetSecondaryDisplay().id());
348c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  CheckInternalDisplay();
349c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  CheckExternalDisplay();
350c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
351c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // Set the primary display back to the internal one.
352c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  SetInternalAsPrimary();
353c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
354c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // Check if displays' touch HUDs are not swapped back as root windows are.
355c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  EXPECT_EQ(internal_display_id(), GetPrimaryDisplay().id());
356c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  EXPECT_EQ(external_display_id(), GetSecondaryDisplay().id());
357c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  CheckInternalDisplay();
358c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  CheckExternalDisplay();
359c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)}
360c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
3611e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// Checks if debug touch HUDs are correctly handled when displays are mirrored.
3621e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)TEST_F(TouchHudDebugTest, MirrorDisplays) {
3637d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)  if (!SupportsMultipleDisplays())
3647d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)    return;
3657d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)
366c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // Setup a dual display setting.
367c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  SetupDualDisplays();
368c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
369c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // Mirror displays.
370c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  MirrorDisplays();
371c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
372c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // Check if the internal display is intact.
373c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  EXPECT_EQ(internal_display_id(), GetPrimaryDisplay().id());
374c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  CheckInternalDisplay();
375c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
376c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // Unmirror displays.
377c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  UnmirrorDisplays();
378c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
379c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // Check if external display is added back correctly.
380c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  EXPECT_EQ(internal_display_id(), GetPrimaryDisplay().id());
381c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  EXPECT_EQ(external_display_id(), GetSecondaryDisplay().id());
382c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  CheckInternalDisplay();
383c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  CheckExternalDisplay();
384c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)}
385c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
3861e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// Checks if debug touch HUDs are correctly handled when displays are mirrored
3871e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// after setting the external display as the primary one.
3881e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)TEST_F(TouchHudDebugTest, SwapPrimaryThenMirrorDisplays) {
3897d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)  if (!SupportsMultipleDisplays())
3907d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)    return;
3917d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)
392c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // Setup a dual display setting.
393c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  SetupDualDisplays();
394c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
395c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // Set the primary display to the external one.
396c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  SetExternalAsPrimary();
397c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
398c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // Mirror displays.
399c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  MirrorDisplays();
400c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
401c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // Check if the internal display is set as the primary one.
402c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  EXPECT_EQ(internal_display_id(), GetPrimaryDisplay().id());
403c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  CheckInternalDisplay();
404c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
405c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // Unmirror displays.
406c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  UnmirrorDisplays();
407c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
408c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // Check if the external display is added back as the primary display and
409c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // touch HUDs are set correctly.
410c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  EXPECT_EQ(external_display_id(), GetPrimaryDisplay().id());
411c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  EXPECT_EQ(internal_display_id(), GetSecondaryDisplay().id());
412c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  CheckInternalDisplay();
413c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  CheckExternalDisplay();
414c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)}
415c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
4161e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// Checks if debug touch HUDs are correctly handled when the external display,
4171e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// which is the secondary one, is removed.
4181e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)TEST_F(TouchHudDebugTest, RemoveSecondaryDisplay) {
4197d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)  if (!SupportsMultipleDisplays())
4207d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)    return;
4217d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)
422c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // Setup a dual display setting.
423c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  SetupDualDisplays();
424c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
425c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // Remove external display which is the secondary one.
426c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  RemoveExternalDisplay();
427c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
428c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // Check if the internal display is intact.
429c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  EXPECT_EQ(internal_display_id(), GetPrimaryDisplay().id());
430c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  CheckInternalDisplay();
431c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
432c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // Add external display back.
433c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  AddExternalDisplay();
434c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
435c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // Check if displays' touch HUDs are set correctly.
436c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  EXPECT_EQ(internal_display_id(), GetPrimaryDisplay().id());
437c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  EXPECT_EQ(external_display_id(), GetSecondaryDisplay().id());
438c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  CheckInternalDisplay();
439c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  CheckExternalDisplay();
440c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)}
441c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
4421e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// Checks if debug touch HUDs are correctly handled when the external display,
4431e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// which is set as the primary display, is removed.
4441e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)TEST_F(TouchHudDebugTest, RemovePrimaryDisplay) {
4457d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)  if (!SupportsMultipleDisplays())
4467d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)    return;
4477d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)
448c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // Setup a dual display setting.
449c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  SetupDualDisplays();
450c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
451c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // Set the primary display to the external one.
452c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  SetExternalAsPrimary();
453c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
454c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // Remove the external display which is the primary display.
455c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  RemoveExternalDisplay();
456c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
457c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // Check if the internal display is set as the primary one.
458c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  EXPECT_EQ(internal_display_id(), GetPrimaryDisplay().id());
459c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  CheckInternalDisplay();
460c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
461c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // Add the external display back.
462c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  AddExternalDisplay();
463c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
464c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // Check if the external display is set as primary and touch HUDs are set
465c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // correctly.
466c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  EXPECT_EQ(external_display_id(), GetPrimaryDisplay().id());
467c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  EXPECT_EQ(internal_display_id(), GetSecondaryDisplay().id());
468c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  CheckInternalDisplay();
469c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  CheckExternalDisplay();
470c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)}
471c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
4721e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// Checks if debug touch HUDs are correctly handled when all displays are
4731e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// removed.
4741e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)TEST_F(TouchHudDebugTest, Headless) {
4757d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)  if (!SupportsMultipleDisplays())
4767d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)    return;
4777d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)
478c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // Setup a single display setting.
479c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  SetupSingleDisplay();
480c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
481c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // Remove the only display which is the internal one.
482c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  RemoveInternalDisplay();
483c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
484c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // Add the internal display back.
485c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  AddInternalDisplay();
486c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
487c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // Check if the display's touch HUD is set correctly.
488c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  EXPECT_EQ(internal_display_id(), GetPrimaryDisplay().id());
489c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  CheckInternalDisplay();
490c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)}
491c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
4921e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// Checks projection touch HUD with a sequence of touch-pressed, touch-moved,
4931e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// and touch-released events.
4941e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)TEST_F(TouchHudProjectionTest, TouchMoveRelease) {
4951e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  SetupSingleDisplay();
4961e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  EXPECT_EQ(NULL, GetInternalTouchHudProjection());
4971e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
4981e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  EnableTouchHudProjection();
499c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch  EXPECT_NE(static_cast<TouchHudProjection*>(NULL),
5001e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)            GetInternalTouchHudProjection());
5011e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  EXPECT_EQ(0, GetInternalTouchPointsCount());
5021e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
5031e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  SendTouchEventToInternalHud(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), 1);
5041e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  EXPECT_EQ(1, GetInternalTouchPointsCount());
5051e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
5061e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  SendTouchEventToInternalHud(ui::ET_TOUCH_MOVED, gfx::Point(10, 20), 1);
5071e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  EXPECT_EQ(1, GetInternalTouchPointsCount());
5081e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
5091e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  SendTouchEventToInternalHud(ui::ET_TOUCH_RELEASED, gfx::Point(10, 20), 1);
5101e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  EXPECT_EQ(0, GetInternalTouchPointsCount());
5111e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
5121e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  // Disabling projection touch HUD shoud remove it without crashing.
5131e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  DisableTouchHudProjection();
5141e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  EXPECT_EQ(NULL, GetInternalTouchHudProjection());
5151e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)}
5161e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
5171e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// Checks projection touch HUD with a sequence of touch-pressed, touch-moved,
5181e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// and touch-cancelled events.
5191e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)TEST_F(TouchHudProjectionTest, TouchMoveCancel) {
5201e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  SetupSingleDisplay();
5211e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  EXPECT_EQ(NULL, GetInternalTouchHudProjection());
5221e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
5231e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  EnableTouchHudProjection();
524c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch  EXPECT_NE(static_cast<TouchHudProjection*>(NULL),
5251e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)            GetInternalTouchHudProjection());
5261e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  EXPECT_EQ(0, GetInternalTouchPointsCount());
5271e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
5281e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  SendTouchEventToInternalHud(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), 1);
5291e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  EXPECT_EQ(1, GetInternalTouchPointsCount());
5301e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
5311e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  SendTouchEventToInternalHud(ui::ET_TOUCH_MOVED, gfx::Point(10, 20), 1);
5321e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  EXPECT_EQ(1, GetInternalTouchPointsCount());
5331e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
5341e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  SendTouchEventToInternalHud(ui::ET_TOUCH_CANCELLED, gfx::Point(10, 20), 1);
5351e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  EXPECT_EQ(0, GetInternalTouchPointsCount());
5361e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
5371e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  // Disabling projection touch HUD shoud remove it without crashing.
5381e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  DisableTouchHudProjection();
5391e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  EXPECT_EQ(NULL, GetInternalTouchHudProjection());
5401e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)}
5411e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
5421e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// Checks projection touch HUD with two simultaneous touches.
5431e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)TEST_F(TouchHudProjectionTest, DoubleTouch) {
5441e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  SetupSingleDisplay();
5451e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  EXPECT_EQ(NULL, GetInternalTouchHudProjection());
5461e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
5471e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  EnableTouchHudProjection();
548c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch  EXPECT_NE(static_cast<TouchHudProjection*>(NULL),
5491e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)            GetInternalTouchHudProjection());
5501e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  EXPECT_EQ(0, GetInternalTouchPointsCount());
5511e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
5521e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  SendTouchEventToInternalHud(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), 1);
5531e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  EXPECT_EQ(1, GetInternalTouchPointsCount());
5541e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
5551e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  SendTouchEventToInternalHud(ui::ET_TOUCH_PRESSED, gfx::Point(20, 10), 2);
5561e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  EXPECT_EQ(2, GetInternalTouchPointsCount());
5571e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
5581e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  SendTouchEventToInternalHud(ui::ET_TOUCH_MOVED, gfx::Point(10, 20), 1);
5591e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  EXPECT_EQ(2, GetInternalTouchPointsCount());
5601e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
5611e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  SendTouchEventToInternalHud(ui::ET_TOUCH_MOVED, gfx::Point(20, 20), 2);
5621e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  EXPECT_EQ(2, GetInternalTouchPointsCount());
5631e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
5641e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  SendTouchEventToInternalHud(ui::ET_TOUCH_RELEASED, gfx::Point(10, 20), 1);
5651e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  EXPECT_EQ(1, GetInternalTouchPointsCount());
5661e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
5671e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  SendTouchEventToInternalHud(ui::ET_TOUCH_RELEASED, gfx::Point(20, 20), 2);
5681e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  EXPECT_EQ(0, GetInternalTouchPointsCount());
5691e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
5701e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  // Disabling projection touch HUD shoud remove it without crashing.
5711e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  DisableTouchHudProjection();
5721e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  EXPECT_EQ(NULL, GetInternalTouchHudProjection());
5731e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)}
5741e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
5751e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// Checks if turning off touch HUD projection while touching the screen is
5761e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// handled correctly.
5771e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)TEST_F(TouchHudProjectionTest, DisableWhileTouching) {
5781e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  SetupSingleDisplay();
5791e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  EXPECT_EQ(NULL, GetInternalTouchHudProjection());
5801e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
5811e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  EnableTouchHudProjection();
582c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch  EXPECT_NE(static_cast<TouchHudProjection*>(NULL),
5831e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)            GetInternalTouchHudProjection());
5841e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  EXPECT_EQ(0, GetInternalTouchPointsCount());
5851e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
5861e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  SendTouchEventToInternalHud(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), 1);
5871e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  EXPECT_EQ(1, GetInternalTouchPointsCount());
5881e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
5891e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  // Disabling projection touch HUD shoud remove it without crashing.
5901e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  DisableTouchHudProjection();
5911e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  EXPECT_EQ(NULL, GetInternalTouchHudProjection());
5921e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)}
5931e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
594c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)}  // namespace ash
595