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/password_manager/core/browser/browser_save_password_progres
s_logger.h" | 5 #include "components/password_manager/core/browser/browser_save_password_progres
s_logger.h" |
6 | 6 |
7 #include "components/password_manager/core/browser/stub_password_manager_client.
h" | 7 #include "components/password_manager/core/browser/stub_password_manager_client.
h" |
8 #include "testing/gmock/include/gmock/gmock.h" | 8 #include "testing/gmock/include/gmock/gmock.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
| 11 using autofill::SavePasswordProgressLogger; |
| 12 |
11 namespace password_manager { | 13 namespace password_manager { |
12 | 14 |
13 namespace { | 15 namespace { |
14 | 16 |
15 const char kTestText[] = "test"; | |
16 | |
17 // The only purpose of TestLogger is to expose SendLog for the test. | 17 // The only purpose of TestLogger is to expose SendLog for the test. |
18 class TestLogger : public BrowserSavePasswordProgressLogger { | 18 class TestLogger : public BrowserSavePasswordProgressLogger { |
19 public: | 19 public: |
20 explicit TestLogger(PasswordManagerClient* client) | 20 explicit TestLogger(PasswordManagerClient* client) |
21 : BrowserSavePasswordProgressLogger(client) {} | 21 : BrowserSavePasswordProgressLogger(client) {} |
22 | 22 |
23 using BrowserSavePasswordProgressLogger::SendLog; | 23 using BrowserSavePasswordProgressLogger::SendLog; |
24 }; | 24 }; |
25 | 25 |
26 class MockPasswordManagerClient : public StubPasswordManagerClient { | 26 class MockPasswordManagerClient : public StubPasswordManagerClient { |
27 public: | 27 public: |
28 MOCK_METHOD1(LogSavePasswordProgress, void(const std::string& text)); | 28 MOCK_METHOD1(LogSavePasswordProgress, |
| 29 void(const std::vector< |
| 30 autofill::SavePasswordProgressLogger::StructuredLog>& logs)); |
29 }; | 31 }; |
30 | 32 |
31 } // namespace | 33 } // namespace |
32 | 34 |
33 TEST(BrowserSavePasswordProgressLoggerTest, SendLog) { | 35 TEST(BrowserSavePasswordProgressLoggerTest, SendLog) { |
34 MockPasswordManagerClient client; | 36 MockPasswordManagerClient client; |
35 TestLogger logger(&client); | 37 TestLogger logger(&client); |
36 EXPECT_CALL(client, LogSavePasswordProgress(kTestText)).Times(1); | 38 std::vector<SavePasswordProgressLogger::StructuredLog> logs; |
37 logger.SendLog(kTestText); | 39 logs.push_back(SavePasswordProgressLogger::StructuredLog( |
| 40 SavePasswordProgressLogger::STRING_MESSAGE)); |
| 41 EXPECT_CALL(client, LogSavePasswordProgress(logs)).Times(1); |
| 42 logger.SendLog(logs); |
38 } | 43 } |
39 | 44 |
40 } // namespace password_manager | 45 } // namespace password_manager |
OLD | NEW |