Chromium Code Reviews| Index: ios/chrome/browser/passwords/password_controller_off_the_record_unittest.mm |
| diff --git a/ios/chrome/browser/passwords/password_controller_off_the_record_unittest.mm b/ios/chrome/browser/passwords/password_controller_off_the_record_unittest.mm |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..eaf26cd741f8699d8243daeebe172f5e080ff78f |
| --- /dev/null |
| +++ b/ios/chrome/browser/passwords/password_controller_off_the_record_unittest.mm |
| @@ -0,0 +1,64 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include <memory> |
| + |
| +#include "base/mac/scoped_nsobject.h" |
|
Eugene But (OOO till 7-30)
2016/07/13 22:30:31
s/include/import
vabr (Chromium)
2016/07/14 07:36:31
Done.
|
| +#include "base/memory/ptr_util.h" |
| +#include "components/password_manager/core/browser/stub_password_manager_client.h" |
| +#include "ios/chrome/browser/browser_state/test_chrome_browser_state.h" |
| +#import "ios/chrome/browser/passwords/password_controller.h" |
| +#include "ios/web/public/test/test_web_state.h" |
|
Eugene But (OOO till 7-30)
2016/07/13 22:30:31
s/include/import
vabr (Chromium)
2016/07/14 07:36:31
Done.
|
| +#import "ios/web/public/test/web_test_with_web_state.h" |
| +#include "testing/gtest/include/gtest/gtest.h" |
| + |
| +namespace { |
| + |
| +class IncognitoPasswordManagerClient |
| + : public password_manager::StubPasswordManagerClient { |
| + public: |
| + bool IsOffTheRecord() const override { return true; } |
| +}; |
| + |
| +} // namespace |
| + |
| +class OffTheRecordWebState : public web::TestWebState { |
| + public: |
| + OffTheRecordWebState() { |
| + TestChromeBrowserState::Builder test_cbs_builder; |
| + chrome_browser_state_ = test_cbs_builder.Build(); |
| + } |
| + |
| + web::BrowserState* GetBrowserState() const override { |
| + return chrome_browser_state_->GetOffTheRecordChromeBrowserState(); |
| + } |
| + |
| + private: |
| + std::unique_ptr<TestChromeBrowserState> chrome_browser_state_; |
| +}; |
| + |
| +class PasswordControllerOffTheRecordTest : public web::WebTestWithWebState { |
| + public: |
| + void SetUp() override { |
| + web::WebTestWithWebState::SetUp(); |
| + password_controller_.reset([[PasswordController alloc] |
| + initWithWebState:&off_the_record_web_state_ |
| + passwordsUiDelegate:nil |
| + client:base::WrapUnique( |
| + new IncognitoPasswordManagerClient())]); |
| + } |
| + |
| + void TearDown() override { |
| + [password_controller_ detach]; |
| + web::WebTestWithWebState::TearDown(); |
| + } |
| + |
| + protected: |
| + OffTheRecordWebState off_the_record_web_state_; |
| + base::scoped_nsobject<PasswordController> password_controller_; |
| +}; |
| + |
| +TEST_F(PasswordControllerOffTheRecordTest, PasswordGenerationDisabled) { |
|
Eugene But (OOO till 7-30)
2016/07/13 22:30:31
If you understand the purpose if these tests, coul
vabr (Chromium)
2016/07/14 07:36:31
Done.
|
| + EXPECT_FALSE([this->password_controller_ passwordGenerationManager]); |
| +} |