| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/autofill/content/renderer/renderer_save_password_progress_l
ogger.h" | 5 #include "components/autofill/content/renderer/renderer_save_password_progress_l
ogger.h" |
| 6 | 6 |
| 7 #include "components/autofill/content/common/autofill_messages.h" | 7 #include "components/autofill/content/common/autofill_messages.h" |
| 8 #include "ipc/ipc_test_sink.h" | 8 #include "ipc/ipc_test_sink.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 // Searches for an |AutofillHostMsg_RecordSavePasswordProgress| message in the | 23 // Searches for an |AutofillHostMsg_RecordSavePasswordProgress| message in the |
| 24 // queue of sent IPC messages. If none is present, returns false. Otherwise, | 24 // queue of sent IPC messages. If none is present, returns false. Otherwise, |
| 25 // extracts the first |AutofillHostMsg_RecordSavePasswordProgress| message, | 25 // extracts the first |AutofillHostMsg_RecordSavePasswordProgress| message, |
| 26 // fills the output parameter with the value of the message's parameter, and | 26 // fills the output parameter with the value of the message's parameter, and |
| 27 // clears the queue of sent messages. | 27 // clears the queue of sent messages. |
| 28 bool GetLogMessage(std::string* log) { | 28 bool GetLogMessage(std::string* log) { |
| 29 const uint32 kMsgID = AutofillHostMsg_RecordSavePasswordProgress::ID; | 29 const uint32 kMsgID = AutofillHostMsg_RecordSavePasswordProgress::ID; |
| 30 const IPC::Message* message = sink_.GetFirstMessageMatching(kMsgID); | 30 const IPC::Message* message = sink_.GetFirstMessageMatching(kMsgID); |
| 31 if (!message) | 31 if (!message) |
| 32 return false; | 32 return false; |
| 33 Tuple<std::string> param; | 33 base::Tuple<std::string> param; |
| 34 AutofillHostMsg_RecordSavePasswordProgress::Read(message, ¶m); | 34 AutofillHostMsg_RecordSavePasswordProgress::Read(message, ¶m); |
| 35 *log = get<0>(param); | 35 *log = base::get<0>(param); |
| 36 sink_.ClearMessages(); | 36 sink_.ClearMessages(); |
| 37 return true; | 37 return true; |
| 38 } | 38 } |
| 39 | 39 |
| 40 private: | 40 private: |
| 41 IPC::TestSink sink_; | 41 IPC::TestSink sink_; |
| 42 }; | 42 }; |
| 43 | 43 |
| 44 } // namespace | 44 } // namespace |
| 45 | 45 |
| 46 TEST(RendererSavePasswordProgressLoggerTest, SendLog) { | 46 TEST(RendererSavePasswordProgressLoggerTest, SendLog) { |
| 47 TestLogger logger; | 47 TestLogger logger; |
| 48 logger.SendLog(kTestText); | 48 logger.SendLog(kTestText); |
| 49 std::string sent_log; | 49 std::string sent_log; |
| 50 EXPECT_TRUE(logger.GetLogMessage(&sent_log)); | 50 EXPECT_TRUE(logger.GetLogMessage(&sent_log)); |
| 51 EXPECT_EQ(kTestText, sent_log); | 51 EXPECT_EQ(kTestText, sent_log); |
| 52 } | 52 } |
| 53 | 53 |
| 54 } // namespace autofill | 54 } // namespace autofill |
| OLD | NEW |