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"
15 const char kTestText
[] = "test";
17 class TestLogger
: public RendererSavePasswordProgressLogger
{
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
);
33 Tuple1
<std::string
> param
;
34 AutofillHostMsg_RecordSavePasswordProgress::Read(message
, ¶m
);
36 sink_
.ClearMessages();
46 TEST(RendererSavePasswordProgressLoggerTest
, SendLog
) {
48 logger
.SendLog(kTestText
);
50 EXPECT_TRUE(logger
.GetLogMessage(&sent_log
));
51 EXPECT_EQ(kTestText
, sent_log
);
54 } // namespace autofill