| 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 "chrome/browser/password_manager/chrome_password_manager_client.h" | 5 #include "chrome/browser/password_manager/chrome_password_manager_client.h" |
| 6 | 6 |
| 7 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 7 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
| 8 #include "components/password_manager/core/browser/password_manager_logger.h" | 8 #include "components/password_manager/core/browser/password_manager_logger.h" |
| 9 #include "content/public/browser/browser_context.h" | 9 #include "content/public/browser/browser_context.h" |
| 10 #include "content/public/browser/web_contents.h" | 10 #include "content/public/browser/web_contents.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 class ChromePasswordManagerClientTest : public ChromeRenderViewHostTestHarness { | 28 class ChromePasswordManagerClientTest : public ChromeRenderViewHostTestHarness { |
| 29 public: | 29 public: |
| 30 virtual void SetUp() OVERRIDE; | 30 virtual void SetUp() OVERRIDE; |
| 31 | 31 |
| 32 protected: | 32 protected: |
| 33 ChromePasswordManagerClient* GetClient(); | 33 ChromePasswordManagerClient* GetClient(); |
| 34 }; | 34 }; |
| 35 | 35 |
| 36 void ChromePasswordManagerClientTest::SetUp() { | 36 void ChromePasswordManagerClientTest::SetUp() { |
| 37 ChromeRenderViewHostTestHarness::SetUp(); | 37 ChromeRenderViewHostTestHarness::SetUp(); |
| 38 ChromePasswordManagerClient::CreateForWebContents(web_contents()); | 38 ChromePasswordManagerClient::CreateForWebContentsWithAutofillManagerDelegate( |
| 39 web_contents(), NULL); |
| 39 } | 40 } |
| 40 | 41 |
| 41 ChromePasswordManagerClient* ChromePasswordManagerClientTest::GetClient() { | 42 ChromePasswordManagerClient* ChromePasswordManagerClientTest::GetClient() { |
| 42 return ChromePasswordManagerClient::FromWebContents(web_contents()); | 43 return ChromePasswordManagerClient::FromWebContents(web_contents()); |
| 43 } | 44 } |
| 44 | 45 |
| 45 TEST_F(ChromePasswordManagerClientTest, LogSavePasswordProgress) { | 46 TEST_F(ChromePasswordManagerClientTest, LogSavePasswordProgress) { |
| 46 ChromePasswordManagerClient* client = GetClient(); | 47 ChromePasswordManagerClient* client = GetClient(); |
| 47 testing::StrictMock<MockPasswordManagerLogger> logger; | 48 testing::StrictMock<MockPasswordManagerLogger> logger; |
| 48 const std::string text("abcd1234"); | 49 const std::string text("abcd1234"); |
| 49 | 50 |
| 50 // Before attaching the logger, no text should be passed. | 51 // Before attaching the logger, no text should be passed. |
| 51 client->LogSavePasswordProgress(text); | 52 client->LogSavePasswordProgress(text); |
| 52 | 53 |
| 53 // After attaching the logger, text should be passed. | 54 // After attaching the logger, text should be passed. |
| 54 client->SetLogger(&logger); | 55 client->SetLogger(&logger); |
| 55 EXPECT_CALL(logger, LogSavePasswordProgress(text)).Times(1); | 56 EXPECT_CALL(logger, LogSavePasswordProgress(text)).Times(1); |
| 56 client->LogSavePasswordProgress(text); | 57 client->LogSavePasswordProgress(text); |
| 57 | 58 |
| 58 // After detaching the logger, no text should be passed again. | 59 // After detaching the logger, no text should be passed again. |
| 59 client->SetLogger(NULL); | 60 client->SetLogger(NULL); |
| 60 client->LogSavePasswordProgress(text); | 61 client->LogSavePasswordProgress(text); |
| 61 } | 62 } |
| OLD | NEW |