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

Side by Side Diff: ui/views/controls/table/table_view_unittest.cc

Issue 9664069: Move scoped_ole_initializer.h to ui/base/win and clean up ole initialization/uninitialization. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « ui/ui.gyp ('k') | ui/views/examples/examples_main.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // For WinDDK ATL compatibility, these ATL headers must come first. 5 // For WinDDK ATL compatibility, these ATL headers must come first.
6 6
7 #include "build/build_config.h" 7 #include "build/build_config.h"
8 8
9 #include <atlbase.h> // NOLINT 9 #include <atlbase.h> // NOLINT
10 #include <atlwin.h> // NOLINT 10 #include <atlwin.h> // NOLINT
11 #include <vector> // NOLINT 11 #include <vector> // NOLINT
12 12
13 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
14 #include "base/message_loop.h" 14 #include "base/message_loop.h"
15 #include "base/string_number_conversions.h" 15 #include "base/string_number_conversions.h"
16 #include "base/utf_string_conversions.h" 16 #include "base/utf_string_conversions.h"
17 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
18 #include "ui/base/models/table_model.h" 18 #include "ui/base/models/table_model.h"
19 #include "ui/base/models/table_model_observer.h" 19 #include "ui/base/models/table_model_observer.h"
20 #include "ui/base/win/scoped_ole_initializer.h"
20 #include "ui/views/controls/table/table_view.h" 21 #include "ui/views/controls/table/table_view.h"
21 #include "ui/views/widget/widget.h" 22 #include "ui/views/widget/widget.h"
22 #include "ui/views/widget/widget_delegate.h" 23 #include "ui/views/widget/widget_delegate.h"
23 24
24 // Put the tests in the views namespace to make it easier to declare them as 25 // Put the tests in the views namespace to make it easier to declare them as
25 // friend classes. 26 // friend classes.
26 namespace views { 27 namespace views {
27 28
28 // TestTableModel -------------------------------------------------------------- 29 // TestTableModel --------------------------------------------------------------
29 30
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 void SetUpMultiSelectTestState(bool sort); 168 void SetUpMultiSelectTestState(bool sort);
168 169
169 scoped_ptr<TestTableModel> model_; 170 scoped_ptr<TestTableModel> model_;
170 171
171 // The table. This is owned by the window. 172 // The table. This is owned by the window.
172 TableView* table_; 173 TableView* table_;
173 174
174 private: 175 private:
175 MessageLoopForUI message_loop_; 176 MessageLoopForUI message_loop_;
176 views::Widget* window_; 177 views::Widget* window_;
178 ui::ScopedOleInitializer ole_initializer_;
177 }; 179 };
178 180
179 void TableViewTest::SetUp() { 181 void TableViewTest::SetUp() {
180 OleInitialize(NULL);
181 model_.reset(CreateModel()); 182 model_.reset(CreateModel());
182 std::vector<ui::TableColumn> columns; 183 std::vector<ui::TableColumn> columns;
183 columns.resize(2); 184 columns.resize(2);
184 columns[0].id = 0; 185 columns[0].id = 0;
185 columns[1].id = 1; 186 columns[1].id = 1;
186 table_ = new TableView(model_.get(), columns, views::ICON_AND_TEXT, 187 table_ = new TableView(model_.get(), columns, views::ICON_AND_TEXT,
187 false, false, false); 188 false, false, false);
188 window_ = views::Widget::CreateWindowWithBounds( 189 window_ = views::Widget::CreateWindowWithBounds(
189 this, 190 this,
190 gfx::Rect(100, 100, 512, 512)); 191 gfx::Rect(100, 100, 512, 512));
191 } 192 }
192 193
193 void TableViewTest::TearDown() { 194 void TableViewTest::TearDown() {
194 window_->Close(); 195 window_->Close();
195 // Temporary workaround to avoid leak of RootView::pending_paint_task_. 196 // Temporary workaround to avoid leak of RootView::pending_paint_task_.
196 message_loop_.RunAllPending(); 197 message_loop_.RunAllPending();
197 OleUninitialize();
198 } 198 }
199 199
200 void TableViewTest::VerifyViewOrder(int first, ...) { 200 void TableViewTest::VerifyViewOrder(int first, ...) {
201 va_list marker; 201 va_list marker;
202 va_start(marker, first); 202 va_start(marker, first);
203 int value = first; 203 int value = first;
204 int index = 0; 204 int index = 0;
205 for (int value = first, index = 0; value != -1; index++) { 205 for (int value = first, index = 0; value != -1; index++) {
206 ASSERT_EQ(value, table_->ViewToModel(index)); 206 ASSERT_EQ(value, table_->ViewToModel(index));
207 value = va_arg(marker, int); 207 value = va_arg(marker, int);
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 VerifySelectedRows(2, 0, -1); 454 VerifySelectedRows(2, 0, -1);
455 } 455 }
456 456
457 // Crashing: http://crbug.com/45015 457 // Crashing: http://crbug.com/45015
458 TEST_F(NullModelTableViewTest, DISABLED_NullModel) { 458 TEST_F(NullModelTableViewTest, DISABLED_NullModel) {
459 // There's nothing explicit to test. If there is a bug in TableView relating 459 // There's nothing explicit to test. If there is a bug in TableView relating
460 // to a NULL model we'll crash. 460 // to a NULL model we'll crash.
461 } 461 }
462 462
463 } // namespace views 463 } // namespace views
OLDNEW
« no previous file with comments | « ui/ui.gyp ('k') | ui/views/examples/examples_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698