This source file includes following definitions.
- loop_
- Send
- IN_PROC_BROWSER_TEST_F
#include "base/command_line.h"
#include "base/memory/scoped_vector.h"
#include "base/message_loop/message_loop.h"
#include "base/stl_util.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/spellchecker/spellcheck_message_filter_mac.h"
#include "chrome/common/spellcheck_messages.h"
#include "chrome/common/spellcheck_result.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "testing/gtest/include/gtest/gtest.h"
class TestingSpellCheckMessageFilter : public SpellCheckMessageFilterMac {
public:
explicit TestingSpellCheckMessageFilter(base::MessageLoopForUI* loop)
: SpellCheckMessageFilterMac(0),
loop_(loop) { }
virtual bool Send(IPC::Message* message) OVERRIDE {
sent_messages_.push_back(message);
loop_->PostTask(FROM_HERE, base::MessageLoop::QuitClosure());
return true;
}
ScopedVector<IPC::Message> sent_messages_;
base::MessageLoopForUI* loop_;
private:
virtual ~TestingSpellCheckMessageFilter() {}
};
typedef InProcessBrowserTest SpellCheckMessageFilterMacBrowserTest;
IN_PROC_BROWSER_TEST_F(SpellCheckMessageFilterMacBrowserTest,
SpellCheckReturnMessage) {
scoped_refptr<TestingSpellCheckMessageFilter> target(
new TestingSpellCheckMessageFilter(base::MessageLoopForUI::current()));
SpellCheckHostMsg_RequestTextCheck to_be_received(
123, 456, base::UTF8ToUTF16("zz."), std::vector<SpellCheckMarker>());
bool handled = false;
target->OnMessageReceived(to_be_received, &handled);
EXPECT_TRUE(handled);
base::MessageLoopForUI::current()->Run();
EXPECT_EQ(1U, target->sent_messages_.size());
int sent_identifier;
std::vector<SpellCheckResult> sent_results;
bool ok = SpellCheckMsg_RespondTextCheck::Read(
target->sent_messages_[0], &sent_identifier, &sent_results);
EXPECT_TRUE(ok);
EXPECT_EQ(1U, sent_results.size());
EXPECT_EQ(sent_results[0].location, 0);
EXPECT_EQ(sent_results[0].length, 2);
EXPECT_EQ(sent_results[0].decoration,
SpellCheckResult::SPELLING);
}