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

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

Issue 2368283002: views: add focus to TabbedPane (Closed)
Patch Set: 2 -> 2.f Created 4 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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 15 matching lines...) Expand all
26 #include "ui/views/test/focus_manager_test.h" 26 #include "ui/views/test/focus_manager_test.h"
27 #include "ui/views/widget/root_view.h" 27 #include "ui/views/widget/root_view.h"
28 #include "ui/views/widget/widget.h" 28 #include "ui/views/widget/widget.h"
29 29
30 using base::ASCIIToUTF16; 30 using base::ASCIIToUTF16;
31 31
32 namespace views { 32 namespace views {
33 33
34 namespace { 34 namespace {
35 35
36 int count = 1; 36 enum {
sky 2016/10/05 20:00:22 enum style for chrome is ALL_CAPS.
Elly Fong-Jones 2016/10/06 16:15:30 This is done... but at what cost??
sky 2016/10/06 21:14:40 Consistency?
37 kTopCheckBoxID = 1, // 1
38 kLeftContainerID,
39 kAppleLabelID,
40 kAppleTextfieldID,
41 kOrangeLabelID, // 5
42 kOrangeTextfieldID,
43 kBananaLabelID,
44 kBananaTextfieldID,
45 kKiwiLabelID,
46 kKiwiTextfieldID, // 10
47 kFruitButtonID,
48 kFruitCheckBoxID,
49 kComboboxID,
37 50
38 const int kTopCheckBoxID = count++; // 1 51 kRightContainerID,
39 const int kLeftContainerID = count++; 52 kAsparagusButtonID, // 15
40 const int kAppleLabelID = count++; 53 kBroccoliButtonID,
41 const int kAppleTextfieldID = count++; 54 kCauliflowerButtonID,
42 const int kOrangeLabelID = count++; // 5
43 const int kOrangeTextfieldID = count++;
44 const int kBananaLabelID = count++;
45 const int kBananaTextfieldID = count++;
46 const int kKiwiLabelID = count++;
47 const int kKiwiTextfieldID = count++; // 10
48 const int kFruitButtonID = count++;
49 const int kFruitCheckBoxID = count++;
50 const int kComboboxID = count++;
51 55
52 const int kRightContainerID = count++; 56 kInnerContainerID,
53 const int kAsparagusButtonID = count++; // 15 57 kScrollViewID,
54 const int kBroccoliButtonID = count++; 58 kRosettaLinkID, // 20
55 const int kCauliflowerButtonID = count++; 59 kStupeurEtTremblementLinkID,
60 kDinerGameLinkID,
61 kRidiculeLinkID,
62 kClosetLinkID,
63 kVisitingLinkID, // 25
64 kAmelieLinkID,
65 kJoyeuxNoelLinkID,
66 kCampingLinkID,
67 kBriceDeNiceLinkID,
68 kTaxiLinkID, // 30
69 kAsterixLinkID,
56 70
57 const int kInnerContainerID = count++; 71 kOKButtonID,
58 const int kScrollViewID = count++; 72 kCancelButtonID,
59 const int kRosettaLinkID = count++; // 20 73 kHelpButtonID,
60 const int kStupeurEtTremblementLinkID = count++;
61 const int kDinerGameLinkID = count++;
62 const int kRidiculeLinkID = count++;
63 const int kClosetLinkID = count++;
64 const int kVisitingLinkID = count++; // 25
65 const int kAmelieLinkID = count++;
66 const int kJoyeuxNoelLinkID = count++;
67 const int kCampingLinkID = count++;
68 const int kBriceDeNiceLinkID = count++;
69 const int kTaxiLinkID = count++; // 30
70 const int kAsterixLinkID = count++;
71 74
72 const int kOKButtonID = count++; 75 kStyleContainerID, // 35
73 const int kCancelButtonID = count++; 76 kBoldCheckBoxID,
74 const int kHelpButtonID = count++; 77 kItalicCheckBoxID,
78 kUnderlinedCheckBoxID,
79 kStyleHelpLinkID,
80 kStyleTextEditID, // 40
75 81
76 const int kStyleContainerID = count++; // 35 82 kSearchContainerID,
77 const int kBoldCheckBoxID = count++; 83 kSearchTextfieldID,
78 const int kItalicCheckBoxID = count++; 84 kSearchButtonID,
79 const int kUnderlinedCheckBoxID = count++; 85 kHelpLinkID,
80 const int kStyleHelpLinkID = count++;
81 const int kStyleTextEditID = count++; // 40
82 86
83 const int kSearchContainerID = count++; 87 kThumbnailContainerID, // 45
84 const int kSearchTextfieldID = count++; 88 kThumbnailStarID,
85 const int kSearchButtonID = count++; 89 kThumbnailSuperStarID,
86 const int kHelpLinkID = count++; 90 };
87
88 const int kThumbnailContainerID = count++; // 45
89 const int kThumbnailStarID = count++;
90 const int kThumbnailSuperStarID = count++;
91 91
92 class DummyComboboxModel : public ui::ComboboxModel { 92 class DummyComboboxModel : public ui::ComboboxModel {
93 public: 93 public:
94 // Overridden from ui::ComboboxModel: 94 // Overridden from ui::ComboboxModel:
95 int GetItemCount() const override { return 10; } 95 int GetItemCount() const override { return 10; }
96 base::string16 GetItemAt(int index) override { 96 base::string16 GetItemAt(int index) override {
97 return ASCIIToUTF16("Item ") + base::IntToString16(index); 97 return ASCIIToUTF16("Item ") + base::IntToString16(index);
98 } 98 }
99 }; 99 };
100 100
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 void InitContentView() override; 185 void InitContentView() override;
186 186
187 protected: 187 protected:
188 FocusTraversalTest(); 188 FocusTraversalTest();
189 189
190 View* FindViewByID(int id) { 190 View* FindViewByID(int id) {
191 View* view = GetContentsView()->GetViewByID(id); 191 View* view = GetContentsView()->GetViewByID(id);
192 if (view) 192 if (view)
193 return view; 193 return view;
194 if (style_tab_) 194 if (style_tab_)
195 view = style_tab_->GetSelectedTab()->GetViewByID(id); 195 view = style_tab_->GetSelectedTabViewForTesting()->GetViewByID(id);
196 if (view) 196 if (view)
197 return view; 197 return view;
198 view = search_border_view_->GetContentsRootView()->GetViewByID(id); 198 view = search_border_view_->GetContentsRootView()->GetViewByID(id);
199 if (view) 199 if (view)
200 return view; 200 return view;
201 return NULL; 201 return NULL;
202 } 202 }
203 203
204 protected: 204 protected:
205 // Helper function to advance focus multiple times in a loop. |traversal_ids| 205 // Helper function to advance focus multiple times in a loop. |traversal_ids|
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 contents->AddChildView(link); 515 contents->AddChildView(link);
516 link->SetBounds(10, 35, 70, 10); 516 link->SetBounds(10, 35, 70, 10);
517 link->set_id(kStyleHelpLinkID); 517 link->set_id(kStyleHelpLinkID);
518 518
519 text_field = new Textfield(); 519 text_field = new Textfield();
520 contents->AddChildView(text_field); 520 contents->AddChildView(text_field);
521 text_field->SetBounds(10, 50, 100, 20); 521 text_field->SetBounds(10, 50, 100, 20);
522 text_field->set_id(kStyleTextEditID); 522 text_field->set_id(kStyleTextEditID);
523 523
524 style_tab_ = new TabbedPane(); 524 style_tab_ = new TabbedPane();
525 style_tab_->set_id(kStyleContainerID);
526 GetContentsView()->AddChildView(style_tab_); 525 GetContentsView()->AddChildView(style_tab_);
527 style_tab_->SetBounds(10, y, 210, 100); 526 style_tab_->SetBounds(10, y, 210, 100);
528 style_tab_->AddTab(ASCIIToUTF16("Style"), contents); 527 style_tab_->AddTab(ASCIIToUTF16("Style"), contents);
528 style_tab_->GetSelectedTabForTesting()->set_id(kStyleContainerID);
529 style_tab_->AddTab(ASCIIToUTF16("Other"), new View()); 529 style_tab_->AddTab(ASCIIToUTF16("Other"), new View());
530 530
531 // Right bottom box with search. 531 // Right bottom box with search.
532 contents = new View(); 532 contents = new View();
533 contents->set_background(Background::CreateSolidBackground(SK_ColorWHITE)); 533 contents->set_background(Background::CreateSolidBackground(SK_ColorWHITE));
534 text_field = new Textfield(); 534 text_field = new Textfield();
535 contents->AddChildView(text_field); 535 contents->AddChildView(text_field);
536 text_field->SetBounds(10, 10, 100, 20); 536 text_field->SetBounds(10, 10, 100, 20);
537 text_field->set_id(kSearchTextfieldID); 537 text_field->set_id(kSearchTextfieldID);
538 538
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
839 GetFocusManager()->AdvanceFocus(false); 839 GetFocusManager()->AdvanceFocus(false);
840 EXPECT_FALSE(GetFocusManager()->GetFocusedView()); 840 EXPECT_FALSE(GetFocusManager()->GetFocusedView());
841 841
842 // Advance backwards from the root node. 842 // Advance backwards from the root node.
843 GetFocusManager()->ClearFocus(); 843 GetFocusManager()->ClearFocus();
844 GetFocusManager()->AdvanceFocus(true); 844 GetFocusManager()->AdvanceFocus(true);
845 EXPECT_FALSE(GetFocusManager()->GetFocusedView()); 845 EXPECT_FALSE(GetFocusManager()->GetFocusedView());
846 } 846 }
847 847
848 } // namespace views 848 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698