Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7922)

Unified Diff: chrome/browser/ui/webui/options/password_manager_handler_unittest.cc

Issue 1951053004: Prevent leaking RenderProcessHosts from PasswordManagerHandlerTest. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/options/password_manager_handler_unittest.cc
diff --git a/chrome/browser/ui/webui/options/password_manager_handler_unittest.cc b/chrome/browser/ui/webui/options/password_manager_handler_unittest.cc
index 6605a28ba44342f4d008cec1db5999ff7e4792ac..be6de5bc2578c086614207521d127b38d8a79806 100644
--- a/chrome/browser/ui/webui/options/password_manager_handler_unittest.cc
+++ b/chrome/browser/ui/webui/options/password_manager_handler_unittest.cc
@@ -10,12 +10,11 @@
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/password_manager/password_store_factory.h"
#include "chrome/browser/ui/passwords/password_manager_presenter.h"
+#include "chrome/test/base/chrome_render_view_host_test_harness.h"
#include "chrome/test/base/testing_profile.h"
#include "components/password_manager/core/browser/mock_password_store.h"
#include "components/password_manager/core/browser/password_manager_test_utils.h"
-#include "content/public/test/test_browser_thread_bundle.h"
#include "content/public/test/test_web_ui.h"
-#include "content/public/test/web_contents_tester.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/shell_dialogs/select_file_dialog.h"
@@ -135,7 +134,8 @@ class MockPasswordManagerPresenter : public PasswordManagerPresenter {
class DummyPasswordManagerHandler : public PasswordUIView {
public:
- DummyPasswordManagerHandler() : password_manager_presenter_(this) {
+ explicit DummyPasswordManagerHandler(Profile* profile)
+ : profile_(profile), password_manager_presenter_(this) {
password_manager_presenter_.Initialize();
}
~DummyPasswordManagerHandler() override {}
@@ -154,7 +154,7 @@ class DummyPasswordManagerHandler : public PasswordUIView {
gfx::NativeWindow GetNativeWindow() const override;
#endif
private:
- TestingProfile profile_;
+ Profile* profile_;
PasswordManagerPresenter password_manager_presenter_;
DISALLOW_COPY_AND_ASSIGN(DummyPasswordManagerHandler);
@@ -167,27 +167,33 @@ gfx::NativeWindow DummyPasswordManagerHandler::GetNativeWindow() const {
#endif
Profile* DummyPasswordManagerHandler::GetProfile() {
- return &profile_;
+ return profile_;
}
} // namespace
-class PasswordManagerHandlerTest : public testing::Test {
+class PasswordManagerHandlerTest : public ChromeRenderViewHostTestHarness {
protected:
- PasswordManagerHandlerTest() {
- dummy_handler_.reset(new DummyPasswordManagerHandler());
+ PasswordManagerHandlerTest() {}
+ ~PasswordManagerHandlerTest() override {}
+
+ void SetUp() override {
+ ChromeRenderViewHostTestHarness::SetUp();
+ dummy_handler_.reset(new DummyPasswordManagerHandler(profile()));
presenter_raw_ = new MockPasswordManagerPresenter(dummy_handler_.get());
- web_contents_ =
- content::WebContentsTester::CreateTestWebContents(&profile_, NULL);
- web_ui_.set_web_contents(web_contents_);
handler_.reset(new TestPasswordManagerHandler(
base::WrapUnique(presenter_raw_), &web_ui_));
handler_->RegisterMessages();
ui::SelectFileDialog::SetFactory(new TestSelectFileDialogFactory);
handler_->InitializeHandler();
+ web_ui_.set_web_contents(web_contents());
}
- ~PasswordManagerHandlerTest() override {}
+ void TearDown() override {
+ handler_.reset();
+ dummy_handler_.reset();
+ ChromeRenderViewHostTestHarness::TearDown();
+ }
void ExportPassword() {
base::ListValue tmp;
@@ -201,14 +207,10 @@ class PasswordManagerHandlerTest : public testing::Test {
PasswordManagerPresenter* presenter_raw_;
CallbackTestWebUI web_ui_;
- content::WebContents* web_contents_;
std::unique_ptr<DummyPasswordManagerHandler> dummy_handler_;
std::unique_ptr<TestPasswordManagerHandler> handler_;
private:
- content::TestBrowserThreadBundle thread_bundle_;
- TestingProfile profile_;
-
DISALLOW_COPY_AND_ASSIGN(PasswordManagerHandlerTest);
};
@@ -218,7 +220,7 @@ MATCHER(IsEmptyPath, "") {
TEST_F(PasswordManagerHandlerTest, PasswordImport) {
EXPECT_CALL(web_ui_, GetWebContents())
- .WillRepeatedly(testing::Return(web_contents_));
+ .WillRepeatedly(testing::Return(web_contents()));
EXPECT_CALL(
*handler_,
FileSelected(IsEmptyPath(), 1,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698