diff options
author | tim@chromium.org <tim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-12 19:48:14 +0000 |
---|---|---|
committer | tim@chromium.org <tim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-12 19:48:14 +0000 |
commit | f1f188943ba5fd66cc54c813d9ed27596a7b29e9 (patch) | |
tree | 7df2007c98faf3b5bd54648c49292f36adbef6ec /chrome/browser | |
parent | e3183473fc3d5135af66b77bc1b2ca7dd834895e (diff) | |
download | chromium_src-f1f188943ba5fd66cc54c813d9ed27596a7b29e9.zip chromium_src-f1f188943ba5fd66cc54c813d9ed27596a7b29e9.tar.gz chromium_src-f1f188943ba5fd66cc54c813d9ed27596a7b29e9.tar.bz2 |
Fix two leaks in SyncSetupWizard test caused by the mock infrastructure
not doing the cleanup that happens in real life.
BUG=19002
TEST=SyncSetupWizardTest
Review URL: http://codereview.chromium.org/164370
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23207 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/views/sync/sync_setup_wizard_unittest.cc | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/chrome/browser/views/sync/sync_setup_wizard_unittest.cc b/chrome/browser/views/sync/sync_setup_wizard_unittest.cc index ee576db..b465f69 100644 --- a/chrome/browser/views/sync/sync_setup_wizard_unittest.cc +++ b/chrome/browser/views/sync/sync_setup_wizard_unittest.cc @@ -1,13 +1,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// TODO(timsteele): Re-enable ASAP. http://crbug.com/19002 -#if 0 #ifdef CHROME_PERSONALIZATION #include "testing/gtest/include/gtest/gtest.h" #include "base/json_writer.h" +#include "base/scoped_ptr.h" +#include "base/stl_util-inl.h" #include "chrome/browser/browser.h" #include "chrome/browser/browser_list.h" #include "chrome/browser/sync/personalization.h" @@ -98,11 +98,22 @@ class TestBrowserWindowForWizardTest : public TestBrowserWindow { was_show_html_dialog_called_(false) { } + virtual ~TestBrowserWindowForWizardTest() { + if (flow_.get()) { + // In real life, the handlers are destroyed by the DOMUI infrastructure, + // which calls GetDOMMessageHandlers to take ownership. This does not + // exist in our test, so we perform cleanup manually. + std::vector<DOMMessageHandler*> handlers; + flow_->GetDOMMessageHandlers(&handlers); + STLDeleteElements(&handlers); + } + } + // We intercept this call to hijack the flow created and then use it to // drive the wizard as if we were the HTML page. virtual void ShowHTMLDialog(HtmlDialogUIDelegate* delegate, gfx::NativeWindow parent_window) { - flow_ = static_cast<SyncSetupFlow*>(delegate); + flow_.reset(static_cast<SyncSetupFlow*>(delegate)); was_show_html_dialog_called_ = true; } @@ -112,7 +123,9 @@ class TestBrowserWindowForWizardTest : public TestBrowserWindow { return ret; } - SyncSetupFlow* flow_; + // In real life, this is owned by the view that is opened by the browser. We + // mock all that out, so we need to take ownership so the flow doesn't leak. + scoped_ptr<SyncSetupFlow> flow_; private: bool was_show_html_dialog_called_; }; @@ -161,7 +174,7 @@ TEST_F(SyncSetupWizardTest, InitialStepLogin) { credentials.Append(new StringValue(auth)); EXPECT_FALSE(wizard_->IsVisible()); - EXPECT_FALSE(test_window_->flow_); + EXPECT_FALSE(test_window_->flow_.get()); wizard_->Step(SyncSetupWizard::GAIA_LOGIN); EXPECT_TRUE(wizard_->IsVisible()); @@ -329,4 +342,4 @@ TEST_F(SyncSetupWizardTest, DiscreteRun) { } #endif // CHROME_PERSONALIZATION -#endif + |