| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/views/select_file_dialog_extension.h" | 5 #include "chrome/browser/ui/views/select_file_dialog_extension.h" |
| 6 | 6 |
| 7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
| 8 #include "ui/base/dialogs/selected_file_info.h" | 8 #include "ui/base/dialogs/selected_file_info.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| 11 class SelectFileDialogExtensionTest : public testing::Test { | 11 class SelectFileDialogExtensionTest : public testing::Test { |
| 12 public: | 12 public: |
| 13 static SelectFileDialogExtension* CreateDialog( | 13 static SelectFileDialogExtension* CreateDialog( |
| 14 SelectFileDialog::Listener* listener, | 14 SelectFileDialog::Listener* listener, |
| 15 int32 tab_id) { | 15 int32 tab_id) { |
| 16 SelectFileDialogExtension* dialog = new SelectFileDialogExtension(listener, | 16 SelectFileDialogExtension* dialog = new SelectFileDialogExtension(listener); |
| 17 NULL); | |
| 18 // Simulate the dialog opening. | 17 // Simulate the dialog opening. |
| 19 EXPECT_FALSE(SelectFileDialogExtension::PendingExists(tab_id)); | 18 EXPECT_FALSE(SelectFileDialogExtension::PendingExists(tab_id)); |
| 20 dialog->AddPending(tab_id); | 19 dialog->AddPending(tab_id); |
| 21 EXPECT_TRUE(SelectFileDialogExtension::PendingExists(tab_id)); | 20 EXPECT_TRUE(SelectFileDialogExtension::PendingExists(tab_id)); |
| 22 return dialog; | 21 return dialog; |
| 23 } | 22 } |
| 24 }; | 23 }; |
| 25 | 24 |
| 26 // Client of a FileManagerDialog that deletes itself whenever the dialog | 25 // Client of a FileManagerDialog that deletes itself whenever the dialog |
| 27 // is closed. | 26 // is closed. |
| (...skipping 23 matching lines...) Expand all Loading... |
| 51 TEST_F(SelectFileDialogExtensionTest, SelfDeleting) { | 50 TEST_F(SelectFileDialogExtensionTest, SelfDeleting) { |
| 52 const int32 kTabId = 123; | 51 const int32 kTabId = 123; |
| 53 SelfDeletingClient* client = new SelfDeletingClient(kTabId); | 52 SelfDeletingClient* client = new SelfDeletingClient(kTabId); |
| 54 // Ensure we don't crash or trip an Address Sanitizer warning about | 53 // Ensure we don't crash or trip an Address Sanitizer warning about |
| 55 // use-after-free. | 54 // use-after-free. |
| 56 ui::SelectedFileInfo file_info; | 55 ui::SelectedFileInfo file_info; |
| 57 SelectFileDialogExtension::OnFileSelected(kTabId, file_info, 0); | 56 SelectFileDialogExtension::OnFileSelected(kTabId, file_info, 0); |
| 58 // Simulate closing the dialog so the listener gets invoked. | 57 // Simulate closing the dialog so the listener gets invoked. |
| 59 client->dialog()->ExtensionDialogClosing(NULL); | 58 client->dialog()->ExtensionDialogClosing(NULL); |
| 60 } | 59 } |
| OLD | NEW |