Commit 6d7f439d authored by Andrew Xu's avatar Andrew Xu Committed by Commit Bot

Eliminate test dependency brought by EventGenerator::PressTouch

EventGenerator::PressTouch would set |is_touch_down_| of aura::Env to
be true. And aura::Env is singleton and shared by test cases. So in CL,
AshTestBase::SetUp is modified to reset aura::Env's properties.

Bug: 586514
Change-Id: Iea96d7fcfc2fba1db857e0d8fe7a1931300cf0cd
Reviewed-on: https://chromium-review.googlesource.com/c/1293174Reviewed-by: default avatarSadrul Chowdhury <sadrul@chromium.org>
Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Commit-Queue: Andrew Xu <andrewxu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#604745}
parent 9912f59a
......@@ -282,10 +282,13 @@ void AshTestHelper::SetUp(bool start_session, bool provide_local_state) {
CreateShell();
// Reset aura::Env to eliminate test dependency (https://crbug.com/586514).
aura::test::EnvTestHelper env_helper(Shell::Get()->aura_env());
env_helper.ResetEnvForTesting();
aura::test::SetEnvForTestWindows(Shell::Get()->aura_env());
aura::test::EnvTestHelper(Shell::Get()->aura_env())
.SetInputStateLookup(std::unique_ptr<aura::InputStateLookup>());
env_helper.SetInputStateLookup(std::unique_ptr<aura::InputStateLookup>());
Shell* shell = Shell::Get();
......
......@@ -315,7 +315,6 @@ Env::Env(Mode mode)
: mode_(mode),
env_controller_(std::make_unique<EnvInputStateController>(this)),
mouse_button_flags_(0),
is_touch_down_(false),
get_last_mouse_location_from_mus_(mode_ == Mode::MUS),
gesture_recognizer_(std::make_unique<ui::GestureRecognizerImpl>()),
input_state_lookup_(InputStateLookup::Create()),
......
......@@ -284,7 +284,7 @@ class AURA_EXPORT Env : public ui::EventTarget,
int mouse_button_flags_;
// Location of last mouse event, in screen coordinates.
mutable gfx::Point last_mouse_location_;
bool is_touch_down_;
bool is_touch_down_ = false;
bool get_last_mouse_location_from_mus_;
// This may be set to true in tests to force using |last_mouse_location_|
// rather than querying WindowTreeClient.
......
......@@ -134,6 +134,10 @@ void AuraTestHelper::SetUp(ui::ContextFactory* context_factory,
}
EnvTestHelper env_helper(env);
// Reset aura::Env to eliminate test dependency (https://crbug.com/586514).
env_helper.ResetEnvForTesting();
if (env_mode == Env::Mode::MUS) {
env_window_tree_client_setter_ =
std::make_unique<EnvWindowTreeClientSetter>(window_tree_client_);
......
......@@ -67,6 +67,10 @@ class EnvTestHelper {
env_->always_use_last_mouse_location_ = value;
}
// Reset aura::Env to eliminate potential test dependency.
// (https://crbug.com/586514)
void ResetEnvForTesting() { env_->is_touch_down_ = false; }
void SetGestureRecognizer(
std::unique_ptr<ui::GestureRecognizer> gesture_recognizer) {
env_->gesture_recognizer_ = std::move(gesture_recognizer);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment