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

Side by Side Diff: ui/views/focus/focus_manager_unittest.cc

Issue 10797046: (Views only): Allow choosing between NativeTabbedPaneView and NativeTabbedPaneWin on Windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: "Fix file header *sigh*" Created 8 years, 4 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/views/controls/tabbed_pane/tabbed_pane_unittest.cc ('k') | ui/views/views.gyp » ('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 #include <utility> 5 #include <utility>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "ui/base/accelerators/accelerator.h" 9 #include "ui/base/accelerators/accelerator.h"
10 #include "ui/base/keycodes/keyboard_codes.h" 10 #include "ui/base/keycodes/keyboard_codes.h"
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 virtual gfx::NativeView TestGetNativeControlView() { 169 virtual gfx::NativeView TestGetNativeControlView() {
170 return native_tabbed_pane_->GetTestingHandle(); 170 return native_tabbed_pane_->GetTestingHandle();
171 } 171 }
172 }; 172 };
173 173
174 // Tests that NativeControls do set the focused View appropriately on the 174 // Tests that NativeControls do set the focused View appropriately on the
175 // FocusManager. 175 // FocusManager.
176 TEST_F(FocusManagerTest, FAILS_FocusNativeControls) { 176 TEST_F(FocusManagerTest, FAILS_FocusNativeControls) {
177 TestTextfield* textfield = new TestTextfield(); 177 TestTextfield* textfield = new TestTextfield();
178 TestTabbedPane* tabbed_pane = new TestTabbedPane(); 178 TestTabbedPane* tabbed_pane = new TestTabbedPane();
179 tabbed_pane->set_use_native_win_control(true);
179 TestTextfield* textfield2 = new TestTextfield(); 180 TestTextfield* textfield2 = new TestTextfield();
180 181
181 GetContentsView()->AddChildView(textfield); 182 GetContentsView()->AddChildView(textfield);
182 GetContentsView()->AddChildView(tabbed_pane); 183 GetContentsView()->AddChildView(tabbed_pane);
183 184
184 tabbed_pane->AddTab(ASCIIToUTF16("Awesome textfield"), textfield2); 185 tabbed_pane->AddTab(ASCIIToUTF16("Awesome textfield"), textfield2);
185 186
186 // Simulate the native view getting the native focus (such as by user click). 187 // Simulate the native view getting the native focus (such as by user click).
187 GetWidget()->FocusNativeView(textfield->TestGetNativeControlView()); 188 GetWidget()->FocusNativeView(textfield->TestGetNativeControlView());
188 EXPECT_EQ(textfield, GetFocusManager()->GetFocusedView()); 189 EXPECT_EQ(textfield, GetFocusManager()->GetFocusedView());
189 190
190 GetWidget()->FocusNativeView(tabbed_pane->TestGetNativeControlView()); 191 GetWidget()->FocusNativeView(tabbed_pane->TestGetNativeControlView());
191 EXPECT_EQ(tabbed_pane, GetFocusManager()->GetFocusedView()); 192 EXPECT_EQ(tabbed_pane, GetFocusManager()->GetFocusedView());
192 193
193 GetWidget()->FocusNativeView(textfield2->TestGetNativeControlView()); 194 GetWidget()->FocusNativeView(textfield2->TestGetNativeControlView());
194 EXPECT_EQ(textfield2, GetFocusManager()->GetFocusedView()); 195 EXPECT_EQ(textfield2, GetFocusManager()->GetFocusedView());
195 } 196 }
196 #endif 197 #endif
197 198
198 // There is no tabbed pane in Aura. 199 // There is no tabbed pane in Aura.
199 #if !defined(USE_AURA) 200 #if !defined(USE_AURA)
200 TEST_F(FocusManagerTest, ContainsView) { 201 TEST_F(FocusManagerTest, ContainsView) {
201 View* view = new View(); 202 View* view = new View();
202 scoped_ptr<View> detached_view(new View()); 203 scoped_ptr<View> detached_view(new View());
203 TabbedPane* tabbed_pane = new TabbedPane(); 204 TabbedPane* tabbed_pane = new TabbedPane();
205 tabbed_pane->set_use_native_win_control(true);
204 TabbedPane* nested_tabbed_pane = new TabbedPane(); 206 TabbedPane* nested_tabbed_pane = new TabbedPane();
207 nested_tabbed_pane->set_use_native_win_control(true);
205 NativeTextButton* tab_button = new NativeTextButton( 208 NativeTextButton* tab_button = new NativeTextButton(
206 NULL, ASCIIToUTF16("tab button")); 209 NULL, ASCIIToUTF16("tab button"));
207 210
208 GetContentsView()->AddChildView(view); 211 GetContentsView()->AddChildView(view);
209 GetContentsView()->AddChildView(tabbed_pane); 212 GetContentsView()->AddChildView(tabbed_pane);
210 // Adding a View inside a TabbedPane to test the case of nested root view. 213 // Adding a View inside a TabbedPane to test the case of nested root view.
211 214
212 tabbed_pane->AddTab(ASCIIToUTF16("Awesome tab"), nested_tabbed_pane); 215 tabbed_pane->AddTab(ASCIIToUTF16("Awesome tab"), nested_tabbed_pane);
213 nested_tabbed_pane->AddTab(ASCIIToUTF16("Awesomer tab"), tab_button); 216 nested_tabbed_pane->AddTab(ASCIIToUTF16("Awesomer tab"), tab_button);
214 217
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 } 621 }
619 622
620 FocusManager* tracked_focus_manager_; 623 FocusManager* tracked_focus_manager_;
621 DtorTrackVector dtor_tracker_; 624 DtorTrackVector dtor_tracker_;
622 }; 625 };
623 626
624 #if !defined(USE_AURA) 627 #if !defined(USE_AURA)
625 TEST_F(FocusManagerDtorTest, FocusManagerDestructedLast) { 628 TEST_F(FocusManagerDtorTest, FocusManagerDestructedLast) {
626 // Setup views hierarchy. 629 // Setup views hierarchy.
627 TabbedPane* tabbed_pane = new TabbedPane(); 630 TabbedPane* tabbed_pane = new TabbedPane();
631 tabbed_pane->set_use_native_win_control(true);
628 GetContentsView()->AddChildView(tabbed_pane); 632 GetContentsView()->AddChildView(tabbed_pane);
629 633
630 NativeButtonDtorTracked* button = new NativeButtonDtorTracked( 634 NativeButtonDtorTracked* button = new NativeButtonDtorTracked(
631 ASCIIToUTF16("button"), &dtor_tracker_); 635 ASCIIToUTF16("button"), &dtor_tracker_);
632 tabbed_pane->AddTab(ASCIIToUTF16("Awesome tab"), button); 636 tabbed_pane->AddTab(ASCIIToUTF16("Awesome tab"), button);
633 637
634 // Close the window. 638 // Close the window.
635 GetWidget()->Close(); 639 GetWidget()->Close();
636 RunPendingMessages(); 640 RunPendingMessages();
637 641
638 // Test window, button and focus manager should all be destructed. 642 // Test window, button and focus manager should all be destructed.
639 ASSERT_EQ(3, static_cast<int>(dtor_tracker_.size())); 643 ASSERT_EQ(3, static_cast<int>(dtor_tracker_.size()));
640 644
641 // Focus manager should be the last one to destruct. 645 // Focus manager should be the last one to destruct.
642 ASSERT_STREQ("FocusManagerDtorTracked", dtor_tracker_[2].c_str()); 646 ASSERT_STREQ("FocusManagerDtorTracked", dtor_tracker_[2].c_str());
643 } 647 }
644 #endif 648 #endif
645 649
646 } // namespace views 650 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/tabbed_pane/tabbed_pane_unittest.cc ('k') | ui/views/views.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698