Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(59)

Unified Diff: content/public/test/browser_test_utils.cc

Issue 1934703002: Fix keyboard focus for OOPIF-<webview>. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed test flakiness and comments in PS 7,8. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/public/test/browser_test_utils.cc
diff --git a/content/public/test/browser_test_utils.cc b/content/public/test/browser_test_utils.cc
index 9ab9738bd8fbc4355a7b93f11dee9c6d0ca52349..011749454e04d77aa073d0dbb0933ca6265e6a98 100644
--- a/content/public/test/browser_test_utils.cc
+++ b/content/public/test/browser_test_utils.cc
@@ -1296,4 +1296,33 @@ uint32_t InputMsgWatcher::WaitForAck() {
return ack_result_;
}
+struct FrameFocusedObserver::FrameTreeNodeObserverImpl
alexmos 2016/06/24 01:38:50 Any reason why this is a struct and not a class?
alexmos 2016/07/26 21:08:30 Still have this question. :)
avallee 2016/07/27 21:35:01 Good point, it's not a POD and should be a class.
+ : public FrameTreeNode::Observer {
+ explicit FrameTreeNodeObserverImpl(FrameTreeNode* owner)
+ : owner_(owner), message_loop_runner_(new MessageLoopRunner) {
+ owner->AddObserver(this);
+ }
+ ~FrameTreeNodeObserverImpl() override { owner_->RemoveObserver(this); }
+
+ void Run() { message_loop_runner_->Run(); }
+
+ void OnFrameTreeNodeFocused(FrameTreeNode* node) override {
+ if (node == owner_)
+ message_loop_runner_->Quit();
+ }
+
+ FrameTreeNode* owner_;
+ scoped_refptr<MessageLoopRunner> message_loop_runner_;
+};
+
+FrameFocusedObserver::FrameFocusedObserver(RenderFrameHost* owner_host)
+ : impl_(new FrameTreeNodeObserverImpl(
+ static_cast<RenderFrameHostImpl*>(owner_host)->frame_tree_node())) {}
+
+FrameFocusedObserver::~FrameFocusedObserver() {}
+
+void FrameFocusedObserver::Wait() {
+ impl_->Run();
+}
+
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698