OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 #include "components/spellcheck/browser/spellcheck_message_filter_platform.h" | 5 #include "components/spellcheck/browser/spellcheck_message_filter_platform.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 remote_results.push_back( | 27 remote_results.push_back( |
28 SpellCheckResult(SpellCheckResult::SPELLING, 0, 5)); | 28 SpellCheckResult(SpellCheckResult::SPELLING, 0, 5)); |
29 | 29 |
30 // Local-only result - must be discarded after combine | 30 // Local-only result - must be discarded after combine |
31 local_results.push_back( | 31 local_results.push_back( |
32 SpellCheckResult(SpellCheckResult::SPELLING, 10, 5)); | 32 SpellCheckResult(SpellCheckResult::SPELLING, 10, 5)); |
33 | 33 |
34 // local & remote result - must be flagged SPELLING, uses remote suggestion. | 34 // local & remote result - must be flagged SPELLING, uses remote suggestion. |
35 SpellCheckResult result(SpellCheckResult::SPELLING, 20, 5, local_suggestion); | 35 SpellCheckResult result(SpellCheckResult::SPELLING, 20, 5, local_suggestion); |
36 local_results.push_back(result); | 36 local_results.push_back(result); |
37 result.replacement = remote_suggestion; | 37 result.replacements[0] = remote_suggestion; |
38 remote_results.push_back(result); | 38 remote_results.push_back(result); |
39 | 39 |
40 SpellCheckMessageFilterPlatform::CombineResults(&remote_results, | 40 SpellCheckMessageFilterPlatform::CombineResults(&remote_results, |
41 local_results); | 41 local_results); |
42 | 42 |
43 ASSERT_EQ(2U, remote_results.size()); | 43 ASSERT_EQ(2U, remote_results.size()); |
44 EXPECT_EQ(SpellCheckResult::GRAMMAR, remote_results[0].decoration); | 44 EXPECT_EQ(SpellCheckResult::GRAMMAR, remote_results[0].decoration); |
45 EXPECT_EQ(0, remote_results[0].location); | 45 EXPECT_EQ(0, remote_results[0].location); |
46 EXPECT_EQ(SpellCheckResult::SPELLING, remote_results[1].decoration); | 46 EXPECT_EQ(SpellCheckResult::SPELLING, remote_results[1].decoration); |
47 EXPECT_EQ(20, remote_results[1].location); | 47 EXPECT_EQ(20, remote_results[1].location); |
48 EXPECT_EQ(remote_suggestion, remote_results[1].replacement); | 48 EXPECT_EQ(remote_suggestion, remote_results[1].replacements[0]); |
49 } | 49 } |
50 | 50 |
51 TEST(SpellCheckMessageFilterPlatformMacTest, TestOverrideThread) { | 51 TEST(SpellCheckMessageFilterPlatformMacTest, TestOverrideThread) { |
52 static const uint32_t kSpellcheckMessages[] = { | 52 static const uint32_t kSpellcheckMessages[] = { |
53 SpellCheckHostMsg_RequestTextCheck::ID, | 53 SpellCheckHostMsg_RequestTextCheck::ID, |
54 }; | 54 }; |
55 scoped_refptr<SpellCheckMessageFilterPlatform> filter( | 55 scoped_refptr<SpellCheckMessageFilterPlatform> filter( |
56 new SpellCheckMessageFilterPlatform(0)); | 56 new SpellCheckMessageFilterPlatform(0)); |
57 content::BrowserThread::ID thread; | 57 content::BrowserThread::ID thread; |
58 IPC::Message message; | 58 IPC::Message message; |
59 for (size_t i = 0; i < arraysize(kSpellcheckMessages); ++i) { | 59 for (size_t i = 0; i < arraysize(kSpellcheckMessages); ++i) { |
60 message.SetHeaderValues( | 60 message.SetHeaderValues( |
61 0, kSpellcheckMessages[i], IPC::Message::PRIORITY_NORMAL); | 61 0, kSpellcheckMessages[i], IPC::Message::PRIORITY_NORMAL); |
62 thread = content::BrowserThread::IO; | 62 thread = content::BrowserThread::IO; |
63 filter->OverrideThreadForMessage(message, &thread); | 63 filter->OverrideThreadForMessage(message, &thread); |
64 EXPECT_EQ(content::BrowserThread::UI, thread); | 64 EXPECT_EQ(content::BrowserThread::UI, thread); |
65 } | 65 } |
66 } | 66 } |
67 | 67 |
68 } // namespace | 68 } // namespace |
OLD | NEW |