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