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

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

Issue 8679020: Move TextInputClientMacTest to content_unittests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « chrome/chrome_tests.gypi ('k') | content/content_tests.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/threading/thread.h" 9 #include "base/threading/thread.h"
10 #include "chrome/test/base/testing_profile.h"
11 #include "content/browser/renderer_host/mock_render_process_host.h" 10 #include "content/browser/renderer_host/mock_render_process_host.h"
12 #include "content/browser/renderer_host/render_process_host_impl.h" 11 #include "content/browser/renderer_host/render_process_host_impl.h"
13 #include "content/browser/renderer_host/render_widget_host.h" 12 #include "content/browser/renderer_host/render_widget_host.h"
14 #include "content/browser/renderer_host/text_input_client_message_filter.h" 13 #include "content/browser/renderer_host/text_input_client_message_filter.h"
15 #include "content/common/text_input_client_messages.h" 14 #include "content/common/text_input_client_messages.h"
15 #include "content/test//test_browser_context.h"
16 #include "ipc/ipc_test_sink.h" 16 #include "ipc/ipc_test_sink.h"
17 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
18 #include "testing/gtest_mac.h" 18 #include "testing/gtest_mac.h"
19 19
20 namespace { 20 namespace {
21 21
22 const int64 kTaskDelayMs = 200; 22 const int64 kTaskDelayMs = 200;
23 23
24 // This test does not test the WebKit side of the dictionary system (which 24 // This test does not test the WebKit side of the dictionary system (which
25 // performs the actual data fetching), but rather this just tests that the 25 // performs the actual data fetching), but rather this just tests that the
26 // service's signaling system works. 26 // service's signaling system works.
27 class TextInputClientMacTest : public testing::Test { 27 class TextInputClientMacTest : public testing::Test {
28 public: 28 public:
29 TextInputClientMacTest() 29 TextInputClientMacTest()
30 : message_loop_(MessageLoop::TYPE_UI), 30 : message_loop_(MessageLoop::TYPE_UI),
31 profile_(), 31 browser_context_(),
32 process_factory_(), 32 process_factory_(),
33 widget_(process_factory_.CreateRenderProcessHost(&profile_), 1), 33 widget_(process_factory_.CreateRenderProcessHost(&browser_context_), 1),
34 thread_("TextInputClientMacTestThread") {} 34 thread_("TextInputClientMacTestThread") {}
35 35
36 // Accessor for the TextInputClientMac instance. 36 // Accessor for the TextInputClientMac instance.
37 TextInputClientMac* service() { 37 TextInputClientMac* service() {
38 return TextInputClientMac::GetInstance(); 38 return TextInputClientMac::GetInstance();
39 } 39 }
40 40
41 // Helper method to post a task on the testing thread's MessageLoop after 41 // Helper method to post a task on the testing thread's MessageLoop after
42 // a short delay. 42 // a short delay.
43 void PostTask(const tracked_objects::Location& from_here, 43 void PostTask(const tracked_objects::Location& from_here,
44 const base::Closure& task, const int64 delay = kTaskDelayMs) { 44 const base::Closure& task, const int64 delay = kTaskDelayMs) {
45 thread_.message_loop()->PostDelayedTask(from_here, task, delay); 45 thread_.message_loop()->PostDelayedTask(from_here, task, delay);
46 } 46 }
47 47
48 RenderWidgetHost* widget() { 48 RenderWidgetHost* widget() {
49 return &widget_; 49 return &widget_;
50 } 50 }
51 51
52 IPC::TestSink& ipc_sink() { 52 IPC::TestSink& ipc_sink() {
53 return static_cast<MockRenderProcessHost*>(widget()->process())->sink(); 53 return static_cast<MockRenderProcessHost*>(widget()->process())->sink();
54 } 54 }
55 55
56 private: 56 private:
57 friend class ScopedTestingThread; 57 friend class ScopedTestingThread;
58 58
59 MessageLoop message_loop_; 59 MessageLoop message_loop_;
60 TestingProfile profile_; 60 TestBrowserContext browser_context_;
61 61
62 // Gets deleted when the last RWH in the "process" gets destroyed. 62 // Gets deleted when the last RWH in the "process" gets destroyed.
63 MockRenderProcessHostFactory process_factory_; 63 MockRenderProcessHostFactory process_factory_;
64 RenderWidgetHost widget_; 64 RenderWidgetHost widget_;
65 65
66 base::Thread thread_; 66 base::Thread thread_;
67 }; 67 };
68 68
69 //////////////////////////////////////////////////////////////////////////////// 69 ////////////////////////////////////////////////////////////////////////////////
70 70
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 TEST_F(TextInputClientMacTest, TimeoutSubstring) { 203 TEST_F(TextInputClientMacTest, TimeoutSubstring) {
204 NSAttributedString* string = service()->GetAttributedSubstringFromRange( 204 NSAttributedString* string = service()->GetAttributedSubstringFromRange(
205 widget(), NSMakeRange(0, 32)); 205 widget(), NSMakeRange(0, 32));
206 EXPECT_EQ(nil, string); 206 EXPECT_EQ(nil, string);
207 EXPECT_EQ(1U, ipc_sink().message_count()); 207 EXPECT_EQ(1U, ipc_sink().message_count());
208 EXPECT_TRUE(ipc_sink().GetUniqueMessageMatching( 208 EXPECT_TRUE(ipc_sink().GetUniqueMessageMatching(
209 TextInputClientMsg_StringForRange::ID)); 209 TextInputClientMsg_StringForRange::ID));
210 } 210 }
211 211
212 } // namespace 212 } // namespace
OLDNEW
« no previous file with comments | « chrome/chrome_tests.gypi ('k') | content/content_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698