OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/ui/webui/options/password_manager_handler.h" | 5 #include "chrome/browser/ui/webui/options/password_manager_handler.h" |
6 | 6 |
7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/metrics/statistics_recorder.h" | 9 #include "base/metrics/statistics_recorder.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
11 #include "chrome/browser/password_manager/password_store_factory.h" | 11 #include "chrome/browser/password_manager/password_store_factory.h" |
12 #include "chrome/browser/ui/passwords/password_manager_presenter.h" | 12 #include "chrome/browser/ui/passwords/password_manager_presenter.h" |
13 #include "chrome/test/base/testing_profile.h" | 13 #include "chrome/test/base/testing_profile.h" |
14 #include "components/password_manager/core/browser/mock_password_store.h" | 14 #include "components/password_manager/core/browser/mock_password_store.h" |
15 #include "components/password_manager/core/browser/password_manager_test_utils.h
" | 15 #include "components/password_manager/core/browser/password_manager_test_utils.h
" |
16 #include "content/public/test/test_browser_thread_bundle.h" | 16 #include "content/public/test/test_browser_thread_bundle.h" |
17 #include "content/public/test/test_web_ui.h" | 17 #include "content/public/test/test_web_ui.h" |
18 #include "content/public/test/web_contents_tester.h" | 18 #include "content/public/test/web_contents_tester.h" |
19 #include "testing/gmock/include/gmock/gmock.h" | 19 #include "testing/gmock/include/gmock/gmock.h" |
20 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
21 #include "ui/shell_dialogs/select_file_dialog.h" | 21 #include "ui/shell_dialogs/select_file_dialog.h" |
22 #include "ui/shell_dialogs/select_file_dialog_factory.h" | 22 #include "ui/shell_dialogs/select_file_dialog_factory.h" |
23 #include "ui/shell_dialogs/select_file_policy.h" | 23 #include "ui/shell_dialogs/select_file_policy.h" |
24 | 24 |
25 using password_manager::MockPasswordStore; | 25 using password_manager::MockPasswordStore; |
26 | 26 |
27 namespace { | 27 namespace { |
| 28 |
28 class TestSelectFileDialogFactory final : public ui::SelectFileDialogFactory { | 29 class TestSelectFileDialogFactory final : public ui::SelectFileDialogFactory { |
29 public: | 30 public: |
30 TestSelectFileDialogFactory() {} | 31 TestSelectFileDialogFactory() {} |
31 ~TestSelectFileDialogFactory() override {} | 32 ~TestSelectFileDialogFactory() override {} |
32 ui::SelectFileDialog* Create(ui::SelectFileDialog::Listener* listener, | 33 ui::SelectFileDialog* Create(ui::SelectFileDialog::Listener* listener, |
33 ui::SelectFilePolicy* policy) override { | 34 ui::SelectFilePolicy* policy) override { |
| 35 delete policy; // Ignore the policy, replace it with a test one. |
34 return new TestSelectFileDialog(listener, new TestSelectFilePolicy); | 36 return new TestSelectFileDialog(listener, new TestSelectFilePolicy); |
35 } | 37 } |
36 | 38 |
37 private: | 39 private: |
38 class TestSelectFilePolicy : public ui::SelectFilePolicy { | 40 class TestSelectFilePolicy : public ui::SelectFilePolicy { |
39 public: | 41 public: |
40 bool CanOpenSelectFileDialog() override { return true; } | 42 bool CanOpenSelectFileDialog() override { return true; } |
41 void SelectFileDenied() override {} | 43 void SelectFileDenied() override {} |
42 }; | 44 }; |
43 | 45 |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 IsUserAuthenticated()) | 233 IsUserAuthenticated()) |
232 .Times(testing::AtLeast(1)) | 234 .Times(testing::AtLeast(1)) |
233 .WillRepeatedly(testing::Return(true)); | 235 .WillRepeatedly(testing::Return(true)); |
234 EXPECT_CALL( | 236 EXPECT_CALL( |
235 *handler_, | 237 *handler_, |
236 FileSelected(IsEmptyPath(), 1, | 238 FileSelected(IsEmptyPath(), 1, |
237 reinterpret_cast<void*>( | 239 reinterpret_cast<void*>( |
238 TestPasswordManagerHandler::EXPORT_FILE_SELECTED))); | 240 TestPasswordManagerHandler::EXPORT_FILE_SELECTED))); |
239 ExportPassword(); | 241 ExportPassword(); |
240 } | 242 } |
OLD | NEW |