Commit 4c2d2c7d authored by Saho Kobayashi's avatar Saho Kobayashi Committed by Commit Bot

refactor arc_accessibility_helper_bridge_unittest.cc by moving...

refactor arc_accessibility_helper_bridge_unittest.cc by moving FilterTypeChange to after TaskAndAXTreeLifecycle.

Bug: b/153618572
Test: ArcAccessibilityHelperBridgeTest.*
Change-Id: Id36aec7ff5698857f9a67c18411cebd5f3759a4b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2152051Reviewed-by: default avatarSara Kato <sarakato@chromium.org>
Commit-Queue: Saho Kobayashi <sahok@chromium.org>
Cr-Commit-Position: refs/heads/master@{#759959}
parent dd7a2abc
...@@ -315,6 +315,69 @@ TEST_F(ArcAccessibilityHelperBridgeTest, TaskAndAXTreeLifecycle) { ...@@ -315,6 +315,69 @@ TEST_F(ArcAccessibilityHelperBridgeTest, TaskAndAXTreeLifecycle) {
ASSERT_EQ(0U, key_to_tree.size()); ASSERT_EQ(0U, key_to_tree.size());
} }
TEST_F(ArcAccessibilityHelperBridgeTest, FilterTypeChange) {
TestArcAccessibilityHelperBridge* helper_bridge =
accessibility_helper_bridge();
const auto& key_to_tree = helper_bridge->trees_for_test();
ASSERT_EQ(0U, key_to_tree.size());
auto event1 = arc::mojom::AccessibilityEventData::New();
event1->source_id = 1;
event1->task_id = 1;
event1->event_type = arc::mojom::AccessibilityEventType::VIEW_FOCUSED;
event1->node_data.push_back(arc::mojom::AccessibilityNodeInfoData::New());
event1->node_data[0]->id = 1;
event1->node_data[0]->string_properties =
base::flat_map<arc::mojom::AccessibilityStringProperty, std::string>();
event1->node_data[0]->string_properties.value().insert(
std::make_pair(arc::mojom::AccessibilityStringProperty::PACKAGE_NAME,
"com.android.vending"));
event1->window_data =
std::vector<arc::mojom::AccessibilityWindowInfoDataPtr>();
event1->window_data->push_back(
arc::mojom::AccessibilityWindowInfoData::New());
arc::mojom::AccessibilityWindowInfoData* root_window1 =
event1->window_data->back().get();
root_window1->window_id = 100;
root_window1->root_node_id = 1;
// There's no active window.
helper_bridge->OnAccessibilityEvent(event1.Clone());
ASSERT_EQ(0U, key_to_tree.size());
// Let's make task 1 active by activating the window.
helper_bridge->SetActiveWindowId(std::string("org.chromium.arc.1"));
helper_bridge->SetFilterTypeForTest(arc::mojom::AccessibilityFilterType::ALL);
helper_bridge->InvokeUpdateEnabledFeatureForTesting();
helper_bridge->OnAccessibilityEvent(event1.Clone());
ASSERT_EQ(1U, key_to_tree.size());
// Changing from ALL to OFF should result in existing trees being destroyed.
helper_bridge->SetFilterTypeForTest(arc::mojom::AccessibilityFilterType::OFF);
helper_bridge->InvokeUpdateEnabledFeatureForTesting();
ASSERT_EQ(0U, key_to_tree.size());
// Changing from OFF to FOCUS should not result in any changes.
helper_bridge->SetFilterTypeForTest(
arc::mojom::AccessibilityFilterType::FOCUS);
helper_bridge->InvokeUpdateEnabledFeatureForTesting();
ASSERT_EQ(0U, key_to_tree.size());
// Changing from FOCUS to ALL should not result in any changes.
helper_bridge->SetFilterTypeForTest(arc::mojom::AccessibilityFilterType::ALL);
helper_bridge->InvokeUpdateEnabledFeatureForTesting();
ASSERT_EQ(0U, key_to_tree.size());
// Dispatch event again, to test changing of filter type from ALL to OFF.
helper_bridge->OnAccessibilityEvent(event1.Clone());
// Changing from ALL to FOCUS should not result in any changes.
helper_bridge->SetFilterTypeForTest(
arc::mojom::AccessibilityFilterType::FOCUS);
helper_bridge->InvokeUpdateEnabledFeatureForTesting();
ASSERT_EQ(0U, key_to_tree.size());
}
TEST_F(ArcAccessibilityHelperBridgeTest, AnnouncementEvent) { TEST_F(ArcAccessibilityHelperBridgeTest, AnnouncementEvent) {
const char* const event_name = extensions::api::accessibility_private:: const char* const event_name = extensions::api::accessibility_private::
OnAnnounceForAccessibility::kEventName; OnAnnounceForAccessibility::kEventName;
...@@ -768,67 +831,4 @@ TEST_F(GetCaptionStyleFromPrefsTests, EmptyValues) { ...@@ -768,67 +831,4 @@ TEST_F(GetCaptionStyleFromPrefsTests, EmptyValues) {
EXPECT_EQ(arc::mojom::CaptionTextShadowType::NONE, style->text_shadow_type); EXPECT_EQ(arc::mojom::CaptionTextShadowType::NONE, style->text_shadow_type);
} }
TEST_F(ArcAccessibilityHelperBridgeTest, FilterTypeChange) {
TestArcAccessibilityHelperBridge* helper_bridge =
accessibility_helper_bridge();
const auto& key_to_tree = helper_bridge->trees_for_test();
ASSERT_EQ(0U, key_to_tree.size());
auto event1 = arc::mojom::AccessibilityEventData::New();
event1->source_id = 1;
event1->task_id = 1;
event1->event_type = arc::mojom::AccessibilityEventType::VIEW_FOCUSED;
event1->node_data.push_back(arc::mojom::AccessibilityNodeInfoData::New());
event1->node_data[0]->id = 1;
event1->node_data[0]->string_properties =
base::flat_map<arc::mojom::AccessibilityStringProperty, std::string>();
event1->node_data[0]->string_properties.value().insert(
std::make_pair(arc::mojom::AccessibilityStringProperty::PACKAGE_NAME,
"com.android.vending"));
event1->window_data =
std::vector<arc::mojom::AccessibilityWindowInfoDataPtr>();
event1->window_data->push_back(
arc::mojom::AccessibilityWindowInfoData::New());
arc::mojom::AccessibilityWindowInfoData* root_window1 =
event1->window_data->back().get();
root_window1->window_id = 100;
root_window1->root_node_id = 1;
// There's no active window.
helper_bridge->OnAccessibilityEvent(event1.Clone());
ASSERT_EQ(0U, key_to_tree.size());
// Let's make task 1 active by activating the window.
helper_bridge->SetActiveWindowId(std::string("org.chromium.arc.1"));
helper_bridge->SetFilterTypeForTest(arc::mojom::AccessibilityFilterType::ALL);
helper_bridge->InvokeUpdateEnabledFeatureForTesting();
helper_bridge->OnAccessibilityEvent(event1.Clone());
ASSERT_EQ(1U, key_to_tree.size());
// Changing from ALL to OFF should result in existing trees being destroyed.
helper_bridge->SetFilterTypeForTest(arc::mojom::AccessibilityFilterType::OFF);
helper_bridge->InvokeUpdateEnabledFeatureForTesting();
ASSERT_EQ(0U, key_to_tree.size());
// Changing from OFF to FOCUS should not result in any changes.
helper_bridge->SetFilterTypeForTest(
arc::mojom::AccessibilityFilterType::FOCUS);
helper_bridge->InvokeUpdateEnabledFeatureForTesting();
ASSERT_EQ(0U, key_to_tree.size());
// Changing from FOCUS to ALL should not result in any changes.
helper_bridge->SetFilterTypeForTest(arc::mojom::AccessibilityFilterType::ALL);
helper_bridge->InvokeUpdateEnabledFeatureForTesting();
ASSERT_EQ(0U, key_to_tree.size());
// Dispatch event again, to test changing of filter type from ALL to OFF.
helper_bridge->OnAccessibilityEvent(event1.Clone());
// Changing from ALL to FOCUS should not result in any changes.
helper_bridge->SetFilterTypeForTest(
arc::mojom::AccessibilityFilterType::FOCUS);
helper_bridge->InvokeUpdateEnabledFeatureForTesting();
ASSERT_EQ(0U, key_to_tree.size());
}
} // namespace arc } // namespace arc
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