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

Side by Side Diff: chrome/browser/ui/views/select_file_dialog_extension_unittest.cc

Issue 628773002: replace OVERRIDE and FINAL with override and final in chrome/browser/ui/[t-v]* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months 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 unified diff | Download patch
OLDNEW
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/files/file_path.h" 7 #include "base/files/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 30 matching lines...) Expand all
41 public: 41 public:
42 TestListener() : selected_(false), file_index_(-1) {} 42 TestListener() : selected_(false), file_index_(-1) {}
43 virtual ~TestListener() {} 43 virtual ~TestListener() {}
44 44
45 bool selected() const { return selected_; } 45 bool selected() const { return selected_; }
46 int file_index() const { return file_index_; } 46 int file_index() const { return file_index_; }
47 47
48 // ui::SelectFileDialog::Listener implementation 48 // ui::SelectFileDialog::Listener implementation
49 virtual void FileSelected(const base::FilePath& path, 49 virtual void FileSelected(const base::FilePath& path,
50 int index, 50 int index,
51 void* params) OVERRIDE { 51 void* params) override {
52 selected_ = true; 52 selected_ = true;
53 file_index_ = index; 53 file_index_ = index;
54 } 54 }
55 55
56 private: 56 private:
57 bool selected_; 57 bool selected_;
58 int file_index_; 58 int file_index_;
59 59
60 DISALLOW_COPY_AND_ASSIGN(TestListener); 60 DISALLOW_COPY_AND_ASSIGN(TestListener);
61 }; 61 };
62 62
63 // Client of a SelectFileDialog that deletes itself whenever the dialog 63 // Client of a SelectFileDialog that deletes itself whenever the dialog
64 // is closed. This is a common pattern in UI code. 64 // is closed. This is a common pattern in UI code.
65 class SelfDeletingClient : public ui::SelectFileDialog::Listener { 65 class SelfDeletingClient : public ui::SelectFileDialog::Listener {
66 public: 66 public:
67 SelfDeletingClient() { 67 SelfDeletingClient() {
68 dialog_ = SelectFileDialogExtensionTest::CreateDialog(this); 68 dialog_ = SelectFileDialogExtensionTest::CreateDialog(this);
69 } 69 }
70 70
71 virtual ~SelfDeletingClient() { 71 virtual ~SelfDeletingClient() {
72 if (dialog_.get()) 72 if (dialog_.get())
73 dialog_->ListenerDestroyed(); 73 dialog_->ListenerDestroyed();
74 } 74 }
75 75
76 SelectFileDialogExtension* dialog() const { return dialog_.get(); } 76 SelectFileDialogExtension* dialog() const { return dialog_.get(); }
77 77
78 // ui::SelectFileDialog::Listener implementation 78 // ui::SelectFileDialog::Listener implementation
79 virtual void FileSelected(const base::FilePath& path, 79 virtual void FileSelected(const base::FilePath& path,
80 int index, 80 int index,
81 void* params) OVERRIDE { 81 void* params) override {
82 delete this; 82 delete this;
83 } 83 }
84 84
85 private: 85 private:
86 scoped_refptr<SelectFileDialogExtension> dialog_; 86 scoped_refptr<SelectFileDialogExtension> dialog_;
87 }; 87 };
88 88
89 TEST_F(SelectFileDialogExtensionTest, FileSelected) { 89 TEST_F(SelectFileDialogExtensionTest, FileSelected) {
90 const int kFileIndex = 5; 90 const int kFileIndex = 5;
91 scoped_ptr<TestListener> listener(new TestListener); 91 scoped_ptr<TestListener> listener(new TestListener);
(...skipping 23 matching lines...) Expand all
115 115
116 TEST_F(SelectFileDialogExtensionTest, SelfDeleting) { 116 TEST_F(SelectFileDialogExtensionTest, SelfDeleting) {
117 SelfDeletingClient* client = new SelfDeletingClient(); 117 SelfDeletingClient* client = new SelfDeletingClient();
118 // Ensure we don't crash or trip an Address Sanitizer warning about 118 // Ensure we don't crash or trip an Address Sanitizer warning about
119 // use-after-free. 119 // use-after-free.
120 ui::SelectedFileInfo file_info; 120 ui::SelectedFileInfo file_info;
121 SelectFileDialogExtension::OnFileSelected(kDefaultRoutingID, file_info, 0); 121 SelectFileDialogExtension::OnFileSelected(kDefaultRoutingID, file_info, 0);
122 // Simulate closing the dialog so the listener gets invoked. 122 // Simulate closing the dialog so the listener gets invoked.
123 client->dialog()->ExtensionDialogClosing(NULL); 123 client->dialog()->ExtensionDialogClosing(NULL);
124 } 124 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/select_file_dialog_extension_factory.h ('k') | chrome/browser/ui/views/session_crashed_bubble_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698