Commit aa2c9bdf authored by Sharon Yang's avatar Sharon Yang Committed by Commit Bot

[Fuchsia] Update AccessibilityBridgeTests so there are no loops

Remove the use of a do while loop in AccessibilityBridgeTests so tests
don't have the opportunity to run indefinitely.
Also remove special handling of the case where this is no root node as
this is now supported by the Semantics Manager.

Testing: CQ

Bug: 973095
Change-Id: I014506bf77fa11b7f33e115b601b9bfaa781b8e2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1924714Reviewed-by: default avatarKevin Marshall <kmarshall@chromium.org>
Commit-Queue: Sharon Yang <yangsharon@chromium.org>
Cr-Commit-Position: refs/heads/master@{#717705}
parent 90afee75
...@@ -82,13 +82,6 @@ void AccessibilityBridge::TryCommit() { ...@@ -82,13 +82,6 @@ void AccessibilityBridge::TryCommit() {
std::move(to_delete_), std::move(to_delete_),
base::BindRepeating( base::BindRepeating(
[](SemanticTree* tree, std::vector<uint32_t> nodes) { [](SemanticTree* tree, std::vector<uint32_t> nodes) {
for (auto i : nodes) {
if (i == 0u) {
// TODO(fxb/41533): Remove this once SemanticsManager supports
// deletion of entire tree.
return;
}
}
tree->DeleteSemanticNodes(std::move(nodes)); tree->DeleteSemanticNodes(std::move(nodes));
}, },
base::Unretained(tree_ptr_.get()))); base::Unretained(tree_ptr_.get())));
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <lib/ui/scenic/cpp/view_token_pair.h> #include <lib/ui/scenic/cpp/view_token_pair.h>
#include <zircon/types.h> #include <zircon/types.h>
#include "base/auto_reset.h"
#include "base/fuchsia/default_context.h" #include "base/fuchsia/default_context.h"
#include "base/fuchsia/scoped_service_binding.h" #include "base/fuchsia/scoped_service_binding.h"
#include "base/fuchsia/service_directory_client.h" #include "base/fuchsia/service_directory_client.h"
...@@ -15,7 +16,6 @@ ...@@ -15,7 +16,6 @@
#include "base/test/bind_test_util.h" #include "base/test/bind_test_util.h"
#include "content/public/browser/web_contents_observer.h" #include "content/public/browser/web_contents_observer.h"
#include "fuchsia/base/frame_test_util.h" #include "fuchsia/base/frame_test_util.h"
#include "fuchsia/base/result_receiver.h"
#include "fuchsia/base/test_navigation_listener.h" #include "fuchsia/base/test_navigation_listener.h"
#include "fuchsia/engine/browser/accessibility_bridge.h" #include "fuchsia/engine/browser/accessibility_bridge.h"
#include "fuchsia/engine/browser/frame_impl.h" #include "fuchsia/engine/browser/frame_impl.h"
...@@ -38,8 +38,8 @@ const char kPage2Title[] = "lots of nodes!"; ...@@ -38,8 +38,8 @@ const char kPage2Title[] = "lots of nodes!";
const char kButtonName[] = "a button"; const char kButtonName[] = "a button";
const char kNodeName[] = "last node"; const char kNodeName[] = "last node";
const char kParagraphName[] = "a third paragraph"; const char kParagraphName[] = "a third paragraph";
const size_t kPage1NodeCount = 5; const size_t kPage1NodeCount = 9;
const size_t kPage2NodeCount = 200; const size_t kPage2NodeCount = 190;
class FakeSemanticTree class FakeSemanticTree
: public fuchsia::accessibility::semantics::testing::SemanticTree_TestBase { : public fuchsia::accessibility::semantics::testing::SemanticTree_TestBase {
...@@ -65,7 +65,7 @@ class FakeSemanticTree ...@@ -65,7 +65,7 @@ class FakeSemanticTree
void CommitUpdates(CommitUpdatesCallback callback) final { void CommitUpdates(CommitUpdatesCallback callback) final {
callback(); callback();
if (on_commit_updates_) if (on_commit_updates_)
std::move(on_commit_updates_).Run(); on_commit_updates_.Run();
} }
void NotImplemented_(const std::string& name) final { void NotImplemented_(const std::string& name) final {
...@@ -74,16 +74,18 @@ class FakeSemanticTree ...@@ -74,16 +74,18 @@ class FakeSemanticTree
void RunUntilNodeCountAtLeast(size_t count) { void RunUntilNodeCountAtLeast(size_t count) {
DCHECK(!on_commit_updates_); DCHECK(!on_commit_updates_);
if (nodes_.size() >= count) if (nodes_.size() >= count)
return; return;
// May take multiple commits before node count is sufficient. base::RunLoop run_loop;
do { base::AutoReset<base::RepeatingClosure> auto_reset(
base::RunLoop run_loop; &on_commit_updates_,
on_commit_updates_ = run_loop.QuitClosure(); base::BindLambdaForTesting([this, count, &run_loop]() {
run_loop.Run(); if (nodes_.size() >= count) {
} while (nodes_.size() < count); run_loop.Quit();
}
}));
run_loop.Run();
} }
bool HasNodeWithLabel(base::StringPiece name) { bool HasNodeWithLabel(base::StringPiece name) {
...@@ -98,7 +100,7 @@ class FakeSemanticTree ...@@ -98,7 +100,7 @@ class FakeSemanticTree
private: private:
std::vector<Node> nodes_; std::vector<Node> nodes_;
base::OnceClosure on_commit_updates_; base::RepeatingClosure on_commit_updates_;
DISALLOW_COPY_AND_ASSIGN(FakeSemanticTree); DISALLOW_COPY_AND_ASSIGN(FakeSemanticTree);
}; };
......
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