Commit 04a53008 authored by Christopher Grant's avatar Christopher Grant Committed by Commit Bot

VR: Clean up hit testability unit test.

Now that we have element types, we can ditch special-casing and remove a
TODO.

BUG=
R=bshe, ymalik

Cq-Include-Trybots: master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel
Change-Id: I22d00c5722f78da4e3bef92ece25ae3231a67981
Reviewed-on: https://chromium-review.googlesource.com/810926
Commit-Queue: Christopher Grant <cjgrant@chromium.org>
Reviewed-by: default avatarYash Malik <ymalik@chromium.org>
Cr-Commit-Position: refs/heads/master@{#522264}
parent c5ca6d38
...@@ -997,6 +997,7 @@ std::unique_ptr<TextInput> UiSceneCreator::CreateTextInput( ...@@ -997,6 +997,7 @@ std::unique_ptr<TextInput> UiSceneCreator::CreateTextInput(
}, },
base::Unretained(text_input_model))); base::Unretained(text_input_model)));
text_input->set_draw_phase(kPhaseNone); text_input->set_draw_phase(kPhaseNone);
text_input->set_hit_testable(false);
text_input->SetTextInputDelegate(text_input_delegate); text_input->SetTextInputDelegate(text_input_delegate);
text_input->AddBinding(base::MakeUnique<Binding<TextInputInfo>>( text_input->AddBinding(base::MakeUnique<Binding<TextInputInfo>>(
base::BindRepeating([](TextInputInfo* info) { return *info; }, base::BindRepeating([](TextInputInfo* info) { return *info; },
......
...@@ -75,10 +75,8 @@ const std::set<UiElementName> kHitTestableElements = { ...@@ -75,10 +75,8 @@ const std::set<UiElementName> kHitTestableElements = {
kWebVrTimeoutMessageButtonText, kWebVrTimeoutMessageButtonText,
kSpeechRecognitionResultBackplane, kSpeechRecognitionResultBackplane,
}; };
const std::set<UiElementName> kSpecialHitTestableElements = { const std::set<UiElementType> kHitTestableElementTypes = {
kCloseButton, kWebVrTimeoutMessageButton, kTypeButtonHitTarget, kTypeTextInputText,
kVoiceSearchButton, kSpeechRecognitionListeningCloseButton,
kOmniboxCloseButton, kOmniboxTextField,
}; };
const std::set<UiElementName> kElementsVisibleWithExitWarning = { const std::set<UiElementName> kElementsVisibleWithExitWarning = {
kScreenDimmer, kExitWarning, kScreenDimmer, kExitWarning,
...@@ -166,30 +164,6 @@ MATCHER_P2(SizeFsAreApproximatelyEqual, other, tolerance, "") { ...@@ -166,30 +164,6 @@ MATCHER_P2(SizeFsAreApproximatelyEqual, other, tolerance, "") {
base::IsApproximatelyEqual(arg.height(), other.height(), tolerance); base::IsApproximatelyEqual(arg.height(), other.height(), tolerance);
} }
void CheckHitTestableRecursive(UiElement* element) {
// This shouldn't be necessary in the future once crbug.com/782395 is fixed.
// we can use class name to identify a child element in a composited element
// such as Button.
if (kSpecialHitTestableElements.find(element->name()) !=
kSpecialHitTestableElements.end()) {
bool has_hittestable_child = false;
for (auto& child : *element) {
if (child.hit_testable())
has_hittestable_child = true;
}
EXPECT_TRUE(has_hittestable_child)
<< "element name: " << UiElementNameToString(element->name());
return;
}
const bool should_be_hit_testable =
kHitTestableElements.find(element->name()) != kHitTestableElements.end();
EXPECT_EQ(should_be_hit_testable, element->hit_testable())
<< "element name: " << UiElementNameToString(element->name());
for (const auto& child : element->children()) {
CheckHitTestableRecursive(child.get());
}
}
void VerifyButtonColor(Button* button, void VerifyButtonColor(Button* button,
SkColor foreground_color, SkColor foreground_color,
SkColor background_color, SkColor background_color,
...@@ -678,8 +652,21 @@ TEST_F(UiTest, PropagateContentBoundsOnFullscreen) { ...@@ -678,8 +652,21 @@ TEST_F(UiTest, PropagateContentBoundsOnFullscreen) {
TEST_F(UiTest, HitTestableElements) { TEST_F(UiTest, HitTestableElements) {
CreateScene(kNotInCct, kNotInWebVr); CreateScene(kNotInCct, kNotInWebVr);
EXPECT_TRUE(RunFor(MsToDelta(0))); for (const auto& element : scene_->root_element()) {
CheckHitTestableRecursive(&scene_->root_element()); if (element.type() != kTypeNone) {
const bool should_be_hit_testable =
kHitTestableElementTypes.find(element.type()) !=
kHitTestableElementTypes.end();
EXPECT_EQ(should_be_hit_testable, element.hit_testable())
<< "element type: " << UiElementTypeToString(element.type());
} else {
const bool should_be_hit_testable =
kHitTestableElements.find(element.name()) !=
kHitTestableElements.end();
EXPECT_EQ(should_be_hit_testable, element.hit_testable())
<< "element name: " << UiElementNameToString(element.name());
}
}
} }
TEST_F(UiTest, DontPropagateContentBoundsOnNegligibleChange) { TEST_F(UiTest, DontPropagateContentBoundsOnNegligibleChange) {
......
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