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

Unified Diff: chrome/browser/ui/views/select_file_dialog_extension_unittest.cc

Issue 8787007: Fix memory leak in unit_test SelectFileDialogExtensionTest (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years 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/views/select_file_dialog_extension_unittest.cc
diff --git a/chrome/browser/ui/views/select_file_dialog_extension_unittest.cc b/chrome/browser/ui/views/select_file_dialog_extension_unittest.cc
index 3c33fbba9b77a5f7045f17c9a1b62c0604c50689..2adcf03b7381760de7e5aba50411124cd9c84121 100644
--- a/chrome/browser/ui/views/select_file_dialog_extension_unittest.cc
+++ b/chrome/browser/ui/views/select_file_dialog_extension_unittest.cc
@@ -34,6 +34,8 @@ class SelfDeletingClient : public SelectFileDialog::Listener {
dialog_->ListenerDestroyed();
}
+ SelectFileDialogExtension* dialog() const { return dialog_.get(); }
+
// SelectFileDialog::Listener implementation
virtual void FileSelected(const FilePath& path,
int index, void* params) OVERRIDE {
@@ -46,10 +48,10 @@ class SelfDeletingClient : public SelectFileDialog::Listener {
TEST_F(SelectFileDialogExtensionTest, SelfDeleting) {
const int32 kTabId = 123;
- // Registers itself with an internal map, so we don't need the pointer,
- // and it would be unused anyway.
- new SelfDeletingClient(kTabId);
+ SelfDeletingClient* client = new SelfDeletingClient(kTabId);
// Ensure we don't crash or trip an Address Sanitizer warning about
// use-after-free.
SelectFileDialogExtension::OnFileSelected(kTabId, FilePath(), 0);
+ // Simulate closing the dialog so the listener gets invoked.
+ client->dialog()->ExtensionDialogClosing(NULL);
}
« 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