| 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 namespace password_manager { | 11 namespace password_manager { |
| 12 | 12 |
| 13 namespace { | 13 namespace { |
| 14 | 14 |
| 15 const char kTestText[] = "test"; | 15 const char kTestText[] = "test"; |
| 16 | 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 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, void(const std::string& text)); |
| 29 }; | 29 }; |
| 30 | 30 |
| 31 } // namespace | 31 } // namespace |
| 32 | 32 |
| 33 TEST(BrowserSavePasswordProgressLoggerTest, SendLog) { | 33 TEST(BrowserSavePasswordProgressLoggerTest, SendLog) { |
| 34 MockPasswordManagerClient client; | 34 MockPasswordManagerClient client; |
| 35 TestLogger logger(&client); | 35 TestLogger logger(&client); |
| 36 EXPECT_CALL(client, LogSavePasswordProgress(kTestText)).Times(1); | 36 EXPECT_CALL(client, LogSavePasswordProgress(kTestText)).Times(1); |
| 37 logger.SendLog(kTestText); | 37 logger.SendLog(kTestText); |
| 38 } | 38 } |
| 39 | 39 |
| 40 } // namespace password_manager | 40 } // namespace password_manager |
| OLD | NEW |