Fix memory leak in unit_test SelectFileDialogExtensionTest

I recently landed a patch that defers the SelectFileDialog::Listener callback until the file picker window is closed.  The test needed to be updated to simulate closing the window so that the Listener would delete itself.

BUG=none
TEST=unit_tests, memory waterfall

Review URL: http://codereview.chromium.org/8787007

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@112830 0039d316-1c4b-4281-b951-d872f2087c98
parent b98e3cb0
...@@ -34,6 +34,8 @@ class SelfDeletingClient : public SelectFileDialog::Listener { ...@@ -34,6 +34,8 @@ class SelfDeletingClient : public SelectFileDialog::Listener {
dialog_->ListenerDestroyed(); dialog_->ListenerDestroyed();
} }
SelectFileDialogExtension* dialog() const { return dialog_.get(); }
// SelectFileDialog::Listener implementation // SelectFileDialog::Listener implementation
virtual void FileSelected(const FilePath& path, virtual void FileSelected(const FilePath& path,
int index, void* params) OVERRIDE { int index, void* params) OVERRIDE {
...@@ -46,10 +48,10 @@ class SelfDeletingClient : public SelectFileDialog::Listener { ...@@ -46,10 +48,10 @@ class SelfDeletingClient : public SelectFileDialog::Listener {
TEST_F(SelectFileDialogExtensionTest, SelfDeleting) { TEST_F(SelectFileDialogExtensionTest, SelfDeleting) {
const int32 kTabId = 123; const int32 kTabId = 123;
// Registers itself with an internal map, so we don't need the pointer, SelfDeletingClient* client = new SelfDeletingClient(kTabId);
// and it would be unused anyway.
new SelfDeletingClient(kTabId);
// Ensure we don't crash or trip an Address Sanitizer warning about // Ensure we don't crash or trip an Address Sanitizer warning about
// use-after-free. // use-after-free.
SelectFileDialogExtension::OnFileSelected(kTabId, FilePath(), 0); SelectFileDialogExtension::OnFileSelected(kTabId, FilePath(), 0);
// Simulate closing the dialog so the listener gets invoked.
client->dialog()->ExtensionDialogClosing(NULL);
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment