Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(86)

Side by Side Diff: components/autofill/content/renderer/renderer_save_password_progress_logger_unittest.cc

Issue 228263004: Password manager internals page: Introduce logger in renderer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comments addressed Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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.
4
5 #include "components/autofill/content/renderer/renderer_save_password_progress_l ogger.h"
6
7 #include "components/autofill/content/common/autofill_messages.h"
8 #include "ipc/ipc_test_sink.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10
11 namespace autofill {
12
13 namespace {
14
15 const char kTestText[] = "test";
16
17 class TestLogger : public RendererSavePasswordProgressLogger {
18 public:
19 TestLogger() : RendererSavePasswordProgressLogger(&sink_, 0) {}
20
21 using RendererSavePasswordProgressLogger::SendLog;
22
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 Tuple1<std::string> param;
34 AutofillHostMsg_RecordSavePasswordProgress::Read(message, &param);
35 *log = param.a;
36 sink_.ClearMessages();
37 return true;
38 }
39
40 private:
41 IPC::TestSink sink_;
42 };
43
44 } // namespace
45
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);
52 }
53
54 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698