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 "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 #include "ui/shell_dialogs/selected_file_info.h" | 9 #include "ui/shell_dialogs/selected_file_info.h" |
10 | 10 |
(...skipping 27 matching lines...) Expand all Loading... |
38 // Test listener for a SelectFileDialog. | 38 // Test listener for a SelectFileDialog. |
39 class TestListener : public ui::SelectFileDialog::Listener { | 39 class TestListener : public ui::SelectFileDialog::Listener { |
40 public: | 40 public: |
41 TestListener() : selected_(false), file_index_(-1) {} | 41 TestListener() : selected_(false), file_index_(-1) {} |
42 virtual ~TestListener() {} | 42 virtual ~TestListener() {} |
43 | 43 |
44 bool selected() const { return selected_; } | 44 bool selected() const { return selected_; } |
45 int file_index() const { return file_index_; } | 45 int file_index() const { return file_index_; } |
46 | 46 |
47 // ui::SelectFileDialog::Listener implementation | 47 // ui::SelectFileDialog::Listener implementation |
48 virtual void FileSelected(const FilePath& path, | 48 virtual void FileSelected(const base::FilePath& path, |
49 int index, | 49 int index, |
50 void* params) OVERRIDE { | 50 void* params) OVERRIDE { |
51 selected_ = true; | 51 selected_ = true; |
52 file_index_ = index; | 52 file_index_ = index; |
53 } | 53 } |
54 | 54 |
55 private: | 55 private: |
56 bool selected_; | 56 bool selected_; |
57 int file_index_; | 57 int file_index_; |
58 | 58 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 | 113 |
114 TEST_F(SelectFileDialogExtensionTest, SelfDeleting) { | 114 TEST_F(SelectFileDialogExtensionTest, SelfDeleting) { |
115 SelfDeletingClient* client = new SelfDeletingClient(); | 115 SelfDeletingClient* client = new SelfDeletingClient(); |
116 // Ensure we don't crash or trip an Address Sanitizer warning about | 116 // Ensure we don't crash or trip an Address Sanitizer warning about |
117 // use-after-free. | 117 // use-after-free. |
118 ui::SelectedFileInfo file_info; | 118 ui::SelectedFileInfo file_info; |
119 SelectFileDialogExtension::OnFileSelected(kDefaultTabId, file_info, 0); | 119 SelectFileDialogExtension::OnFileSelected(kDefaultTabId, file_info, 0); |
120 // Simulate closing the dialog so the listener gets invoked. | 120 // Simulate closing the dialog so the listener gets invoked. |
121 client->dialog()->ExtensionDialogClosing(NULL); | 121 client->dialog()->ExtensionDialogClosing(NULL); |
122 } | 122 } |
OLD | NEW |