This source file includes following definitions.
- TEST
- TEST
#include "chrome/browser/spellchecker/spellcheck_message_filter_mac.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/common/spellcheck_messages.h"
#include "chrome/common/spellcheck_result.h"
#include "content/public/browser/browser_thread.h"
#include "ipc/ipc_message.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace {
TEST(SpellcheckMessageFilterMacTest, CombineResults) {
std::vector<SpellCheckResult> local_results;
std::vector<SpellCheckResult> remote_results;
base::string16 remote_suggestion = base::ASCIIToUTF16("remote");
base::string16 local_suggestion = base::ASCIIToUTF16("local");
remote_results.push_back(
SpellCheckResult(SpellCheckResult::SPELLING, 0, 5));
local_results.push_back(
SpellCheckResult(SpellCheckResult::SPELLING, 10, 5));
SpellCheckResult result(SpellCheckResult::SPELLING, 20, 5, local_suggestion);
local_results.push_back(result);
result.replacement = remote_suggestion;
remote_results.push_back(result);
SpellCheckMessageFilterMac::CombineResults(&remote_results, local_results);
ASSERT_EQ(2U, remote_results.size());
EXPECT_EQ(SpellCheckResult::GRAMMAR, remote_results[0].decoration);
EXPECT_EQ(0, remote_results[0].location);
EXPECT_EQ(SpellCheckResult::SPELLING, remote_results[1].decoration);
EXPECT_EQ(20, remote_results[1].location);
EXPECT_EQ(remote_suggestion, remote_results[1].replacement);
}
TEST(SpellCheckMessageFilterMacTest, TestOverrideThread) {
static const uint32 kSpellcheckMessages[] = {
SpellCheckHostMsg_RequestTextCheck::ID,
};
scoped_refptr<SpellCheckMessageFilterMac> filter(
new SpellCheckMessageFilterMac(0));
content::BrowserThread::ID thread;
IPC::Message message;
for (size_t i = 0; i < arraysize(kSpellcheckMessages); ++i) {
message.SetHeaderValues(
0, kSpellcheckMessages[i], IPC::Message::PRIORITY_NORMAL);
thread = content::BrowserThread::IO;
filter->OverrideThreadForMessage(message, &thread);
EXPECT_EQ(content::BrowserThread::UI, thread);
}
}
}