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

Side by Side Diff: content/browser/renderer_host/text_input_client_mac_unittest.mm

Issue 2840593002: Remove usage of ScopedTaskScheduler. (Closed)
Patch Set: rebase Created 3 years, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "content/browser/renderer_host/text_input_client_mac.h" 5 #import "content/browser/renderer_host/text_input_client_mac.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/message_loop/message_loop.h"
12 #include "base/run_loop.h" 11 #include "base/run_loop.h"
13 #include "base/single_thread_task_runner.h" 12 #include "base/single_thread_task_runner.h"
14 #include "base/test/scoped_task_scheduler.h" 13 #include "base/test/scoped_task_environment.h"
15 #include "base/threading/thread.h" 14 #include "base/threading/thread.h"
16 #include "content/browser/renderer_host/render_process_host_impl.h" 15 #include "content/browser/renderer_host/render_process_host_impl.h"
17 #include "content/browser/renderer_host/render_widget_host_delegate.h" 16 #include "content/browser/renderer_host/render_widget_host_delegate.h"
18 #include "content/browser/renderer_host/render_widget_host_impl.h" 17 #include "content/browser/renderer_host/render_widget_host_impl.h"
19 #include "content/browser/renderer_host/text_input_client_message_filter.h" 18 #include "content/browser/renderer_host/text_input_client_message_filter.h"
20 #include "content/common/text_input_client_messages.h" 19 #include "content/common/text_input_client_messages.h"
21 #include "content/public/test/mock_render_process_host.h" 20 #include "content/public/test/mock_render_process_host.h"
22 #include "content/public/test/test_browser_context.h" 21 #include "content/public/test/test_browser_context.h"
23 #include "ipc/ipc_test_sink.h" 22 #include "ipc/ipc_test_sink.h"
24 #include "testing/gtest/include/gtest/gtest.h" 23 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 15 matching lines...) Expand all
40 void Paste() override {} 39 void Paste() override {}
41 void SelectAll() override {} 40 void SelectAll() override {}
42 }; 41 };
43 42
44 // This test does not test the WebKit side of the dictionary system (which 43 // This test does not test the WebKit side of the dictionary system (which
45 // performs the actual data fetching), but rather this just tests that the 44 // performs the actual data fetching), but rather this just tests that the
46 // service's signaling system works. 45 // service's signaling system works.
47 class TextInputClientMacTest : public testing::Test { 46 class TextInputClientMacTest : public testing::Test {
48 public: 47 public:
49 TextInputClientMacTest() 48 TextInputClientMacTest()
50 : task_scheduler_(&message_loop_), 49 : browser_context_(),
51 browser_context_(),
52 process_factory_(), 50 process_factory_(),
53 delegate_(), 51 delegate_(),
54 thread_("TextInputClientMacTestThread") { 52 thread_("TextInputClientMacTestThread") {
55 RenderProcessHost* rph = 53 RenderProcessHost* rph =
56 process_factory_.CreateRenderProcessHost(&browser_context_, nullptr); 54 process_factory_.CreateRenderProcessHost(&browser_context_, nullptr);
57 int32_t routing_id = rph->GetNextRoutingID(); 55 int32_t routing_id = rph->GetNextRoutingID();
58 widget_.reset(new RenderWidgetHostImpl(&delegate_, rph, routing_id, false)); 56 widget_.reset(new RenderWidgetHostImpl(&delegate_, rph, routing_id, false));
59 } 57 }
60 58
61 void TearDown() override { 59 void TearDown() override {
(...skipping 25 matching lines...) Expand all
87 85
88 RenderWidgetHostImpl* widget() { return widget_.get(); } 86 RenderWidgetHostImpl* widget() { return widget_.get(); }
89 87
90 IPC::TestSink& ipc_sink() { 88 IPC::TestSink& ipc_sink() {
91 return static_cast<MockRenderProcessHost*>(widget()->GetProcess())->sink(); 89 return static_cast<MockRenderProcessHost*>(widget()->GetProcess())->sink();
92 } 90 }
93 91
94 private: 92 private:
95 friend class ScopedTestingThread; 93 friend class ScopedTestingThread;
96 94
97 base::MessageLoopForUI message_loop_;
gab 2017/05/01 19:05:04 ForUI?
fdoray 2017/05/03 17:38:14 Done.
98
99 // TaskScheduler is used by RenderWidgetHostImpl constructor. 95 // TaskScheduler is used by RenderWidgetHostImpl constructor.
100 base::test::ScopedTaskScheduler task_scheduler_; 96 base::test::ScopedTaskEnvironment scoped_task_environment_;
101 97
102 TestBrowserContext browser_context_; 98 TestBrowserContext browser_context_;
103 99
104 // Gets deleted when the last RWH in the "process" gets destroyed. 100 // Gets deleted when the last RWH in the "process" gets destroyed.
105 MockRenderProcessHostFactory process_factory_; 101 MockRenderProcessHostFactory process_factory_;
106 MockRenderWidgetHostDelegate delegate_; 102 MockRenderWidgetHostDelegate delegate_;
107 std::unique_ptr<RenderWidgetHostImpl> widget_; 103 std::unique_ptr<RenderWidgetHostImpl> widget_;
108 104
109 base::Thread thread_; 105 base::Thread thread_;
110 }; 106 };
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 209
214 TEST_F(TextInputClientMacTest, TimeoutRectForRange) { 210 TEST_F(TextInputClientMacTest, TimeoutRectForRange) {
215 NSRect rect = service()->GetFirstRectForRange(widget(), NSMakeRange(0, 32)); 211 NSRect rect = service()->GetFirstRectForRange(widget(), NSMakeRange(0, 32));
216 EXPECT_EQ(1U, ipc_sink().message_count()); 212 EXPECT_EQ(1U, ipc_sink().message_count());
217 EXPECT_TRUE(ipc_sink().GetUniqueMessageMatching( 213 EXPECT_TRUE(ipc_sink().GetUniqueMessageMatching(
218 TextInputClientMsg_FirstRectForCharacterRange::ID)); 214 TextInputClientMsg_FirstRectForCharacterRange::ID));
219 EXPECT_NSEQ(NSZeroRect, rect); 215 EXPECT_NSEQ(NSZeroRect, rect);
220 } 216 }
221 217
222 } // namespace content 218 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698