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

Unified Diff: content/browser/renderer_host/text_input_client_mac_unittest.mm

Issue 2785883004: Add missing TaskScheduler on tests using RendereWidgetHostImpl (Closed)
Patch Set: yet another mac fix Created 3 years, 9 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/browser/renderer_host/text_input_client_mac_unittest.mm
diff --git a/content/browser/renderer_host/text_input_client_mac_unittest.mm b/content/browser/renderer_host/text_input_client_mac_unittest.mm
index ac50233e1993471886b4fbad9f217c03ed9c1232..3bb9df5cab2da2191b84628a2e2ea52a471c1697 100644
--- a/content/browser/renderer_host/text_input_client_mac_unittest.mm
+++ b/content/browser/renderer_host/text_input_client_mac_unittest.mm
@@ -9,7 +9,9 @@
#include "base/bind.h"
#include "base/message_loop/message_loop.h"
+#include "base/run_loop.h"
#include "base/single_thread_task_runner.h"
+#include "base/test/scoped_task_scheduler.h"
#include "base/threading/thread.h"
#include "content/browser/renderer_host/render_process_host_impl.h"
#include "content/browser/renderer_host/render_widget_host_delegate.h"
@@ -45,7 +47,8 @@ class MockRenderWidgetHostDelegate : public RenderWidgetHostDelegate {
class TextInputClientMacTest : public testing::Test {
public:
TextInputClientMacTest()
- : browser_context_(),
+ : task_scheduler_(&message_loop_),
+ browser_context_(),
process_factory_(),
delegate_(),
thread_("TextInputClientMacTestThread") {
@@ -55,6 +58,15 @@ class TextInputClientMacTest : public testing::Test {
widget_.reset(new RenderWidgetHostImpl(&delegate_, rph, routing_id, false));
}
+ void TearDown() override {
+ // |widget_| needs to be cleared before flushing the message loop, otherwise
+ // |widgets_|'s destructor calls MockRenderProcessHost::Cleanup, it
+ // schedules the MRPH deletion, and then MockRenderProcessHostFactory also
+ // deletes the MRPH before scheduled MRPH deletion is invoked.
kinuko 2017/03/31 14:26:55 Whoa.
+ widget_.reset();
+ base::RunLoop().RunUntilIdle();
+ }
+
// Accessor for the TextInputClientMac instance.
TextInputClientMac* service() {
return TextInputClientMac::GetInstance();
@@ -83,6 +95,10 @@ class TextInputClientMacTest : public testing::Test {
friend class ScopedTestingThread;
base::MessageLoopForUI message_loop_;
+
+ // TaskScheduler is used by RenderWidgetHostImpl constructor.
+ base::test::ScopedTaskScheduler task_scheduler_;
+
TestBrowserContext browser_context_;
// Gets deleted when the last RWH in the "process" gets destroyed.

Powered by Google App Engine
This is Rietveld 408576698