Move Tuple to base namespace.
[chromium-blink-merge.git] / components / autofill / content / renderer / renderer_save_password_progress_logger_unittest.cc
blobe9fd7fd9e5918ec0ffb5ad24479d802104c3052b
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "components/autofill/content/renderer/renderer_save_password_progress_logger.h"
7 #include "components/autofill/content/common/autofill_messages.h"
8 #include "ipc/ipc_test_sink.h"
9 #include "testing/gtest/include/gtest/gtest.h"
11 namespace autofill {
13 namespace {
15 const char kTestText[] = "test";
17 class TestLogger : public RendererSavePasswordProgressLogger {
18 public:
19 TestLogger() : RendererSavePasswordProgressLogger(&sink_, 0) {}
21 using RendererSavePasswordProgressLogger::SendLog;
23 // Searches for an |AutofillHostMsg_RecordSavePasswordProgress| message in the
24 // queue of sent IPC messages. If none is present, returns false. Otherwise,
25 // extracts the first |AutofillHostMsg_RecordSavePasswordProgress| message,
26 // fills the output parameter with the value of the message's parameter, and
27 // clears the queue of sent messages.
28 bool GetLogMessage(std::string* log) {
29 const uint32 kMsgID = AutofillHostMsg_RecordSavePasswordProgress::ID;
30 const IPC::Message* message = sink_.GetFirstMessageMatching(kMsgID);
31 if (!message)
32 return false;
33 base::Tuple<std::string> param;
34 AutofillHostMsg_RecordSavePasswordProgress::Read(message, &param);
35 *log = base::get<0>(param);
36 sink_.ClearMessages();
37 return true;
40 private:
41 IPC::TestSink sink_;
44 } // namespace
46 TEST(RendererSavePasswordProgressLoggerTest, SendLog) {
47 TestLogger logger;
48 logger.SendLog(kTestText);
49 std::string sent_log;
50 EXPECT_TRUE(logger.GetLogMessage(&sent_log));
51 EXPECT_EQ(kTestText, sent_log);
54 } // namespace autofill