summaryrefslogtreecommitdiffstats
path: root/chrome/views/focus_manager_unittest.cc
blob: 30f7e857d8964b7ccf15e8bdb620f9730c15a9f7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Disabled right now as this won't work on BuildBots right now as this test
// require the box it runs on to be unlocked (and no screen-savers).
// The test actually simulates mouse and key events, so if the screen is locked,
// the events don't go to the Chrome window.
#include "testing/gtest/include/gtest/gtest.h"

#include "base/gfx/rect.h"
#include "chrome/common/resource_bundle.h"
#include "chrome/views/accelerator_handler.h"
#include "chrome/views/background.h"
#include "chrome/views/border.h"
#include "chrome/views/checkbox.h"
#include "chrome/views/label.h"
#include "chrome/views/link.h"
#include "chrome/views/native_button.h"
#include "chrome/views/radio_button.h"
#include "chrome/views/root_view.h"
#include "chrome/views/scroll_view.h"
#include "chrome/views/tabbed_pane.h"
#include "chrome/views/text_field.h"
#include "chrome/views/widget_win.h"
#include "chrome/views/window.h"
#include "chrome/views/window_delegate.h"
#include "SkColor.h"


namespace {

static const int kWindowWidth = 600;
static const int kWindowHeight = 500;

static int count = 1;

static const int kTopCheckBoxID = count++;  // 1
static const int kLeftContainerID = count++;
static const int kAppleLabelID = count++;
static const int kAppleTextFieldID = count++;
static const int kOrangeLabelID = count++;  // 5
static const int kOrangeTextFieldID = count++;
static const int kBananaLabelID = count++;
static const int kBananaTextFieldID = count++;
static const int kKiwiLabelID = count++;
static const int kKiwiTextFieldID = count++; // 10
static const int kFruitButtonID = count++;
static const int kFruitCheckBoxID = count++;

static const int kRightContainerID = count++;
static const int kAsparagusButtonID = count++;
static const int kBroccoliButtonID = count++;  // 15
static const int kCauliflowerButtonID = count++;

static const int kInnerContainerID = count++;
static const int kScrollViewID = count++;
static const int kScrollContentViewID = count++;
static const int kRosettaLinkID = count++;  // 20
static const int kStupeurEtTremblementLinkID = count++;
static const int kDinerGameLinkID = count++;
static const int kRidiculeLinkID = count++;
static const int kClosetLinkID = count++;
static const int kVisitingLinkID = count++;  // 25
static const int kAmelieLinkID = count++;
static const int kJoyeuxNoelLinkID = count++;
static const int kCampingLinkID = count++;
static const int kBriceDeNiceLinkID = count++;
static const int kTaxiLinkID = count++;  // 30
static const int kAsterixLinkID = count++;

static const int kOKButtonID = count++;
static const int kCancelButtonID = count++;
static const int kHelpButtonID = count++;

static const int kStyleContainerID = count++;  // 35
static const int kBoldCheckBoxID = count++;
static const int kItalicCheckBoxID = count++;
static const int kUnderlinedCheckBoxID = count++;

static const int kSearchContainerID = count++;
static const int kSearchTextFieldID = count++;  // 40
static const int kSearchButtonID = count++;
static const int kHelpLinkID = count++;

static const int kThumbnailContainerID = count++;
static const int kThumbnailStarID = count++;
static const int kThumbnailSuperStarID = count++;

class FocusManagerTest;

// BorderView is a NativeControl that creates a tab control as its child and
// takes a View to add as the child of the tab control. The tab control is used
// to give a nice background for the view. At some point we'll have a real
// wrapper for TabControl, and this can be nuked in favor of it.
// Taken from keyword_editor_view.cc.
// It is interesting in our test as it is a native control containing another
// RootView.
class BorderView : public views::NativeControl {
 public:
  explicit BorderView(View* child) : child_(child) {
    DCHECK(child);
    SetFocusable(false);
  }

  virtual ~BorderView() {}

  virtual HWND CreateNativeControl(HWND parent_container) {
    // Create the tab control.
    HWND tab_control = ::CreateWindowEx(GetAdditionalExStyle(),
                                        WC_TABCONTROL,
                                        L"",
                                        WS_CHILD,
                                        0, 0, width(), height(),
                                        parent_container, NULL, NULL, NULL);
    // Create the view container which is a child of the TabControl.
    widget_ = new views::WidgetWin();
    widget_->Init(tab_control, gfx::Rect(), false);
    widget_->SetContentsView(child_);
    widget_->SetFocusTraversableParentView(this);
    ResizeContents(tab_control);
    return tab_control;
  }

  virtual LRESULT OnNotify(int w_param, LPNMHDR l_param) {
    return 0;
  }

  virtual void Layout() {
    NativeControl::Layout();
    ResizeContents(GetNativeControlHWND());
  }

  virtual views::RootView* GetContentsRootView() {
    return widget_->GetRootView();
  }

  virtual views::FocusTraversable* GetFocusTraversable() {
    return widget_;
  }

  virtual void ViewHierarchyChanged(bool is_add, View *parent, View *child) {
    NativeControl::ViewHierarchyChanged(is_add, parent, child);

    if (child == this && is_add) {
      // We have been added to a view hierarchy, update the FocusTraversable
      // parent.
      widget_->SetFocusTraversableParent(GetRootView());
    }
  }

private:
  void ResizeContents(HWND tab_control) {
    DCHECK(tab_control);
    CRect content_bounds;
    if (!GetClientRect(tab_control, &content_bounds))
      return;
    TabCtrl_AdjustRect(tab_control, FALSE, &content_bounds);
    widget_->MoveWindow(content_bounds.left, content_bounds.top,
      content_bounds.Width(), content_bounds.Height(),
      TRUE);
  }

  View* child_;
  views::WidgetWin* widget_;

  DISALLOW_EVIL_CONSTRUCTORS(BorderView);
};

class TestViewWindow : public views::WidgetWin {
 public:
  explicit TestViewWindow(FocusManagerTest* test);
  ~TestViewWindow() { }

  void Init();

  views::View* contents() const { return contents_; }
  

  // Return the ID of the component that currently has the focus.
  int GetFocusedComponentID();

  // Simulate pressing the tab button in the window.
  void PressTab(bool shift_pressed, bool ctrl_pressed);

  views::RootView* GetContentsRootView() const {
    return contents_->GetRootView();
  }

  views::RootView* GetStyleRootView() const {
    return style_tab_->GetContentsRootView();
  }

  views::RootView* GetSearchRootView() const {
    return search_border_view_->GetContentsRootView();
  }

 private:
  views::View* contents_;

  views::TabbedPane* style_tab_;
  BorderView* search_border_view_;

  FocusManagerTest* test_;

  DISALLOW_EVIL_CONSTRUCTORS(TestViewWindow);
};

class FocusManagerTest : public testing::Test {
 public:
  TestViewWindow* GetWindow();
  ~FocusManagerTest();

 protected:
  FocusManagerTest();

  virtual void SetUp();
  virtual void TearDown();

  MessageLoopForUI message_loop_;
  TestViewWindow* test_window_;
};

////////////////////////////////////////////////////////////////////////////////
// TestViewWindow
////////////////////////////////////////////////////////////////////////////////

TestViewWindow::TestViewWindow(FocusManagerTest* test)
    : test_(test),
      contents_(NULL),
      style_tab_(NULL),
      search_border_view_(NULL) {
}

// Initializes and shows the window with the contents view.
void TestViewWindow::Init() {
  gfx::Rect bounds(0, 0, 600, 460);
  contents_ = new views::View();
  contents_->set_background(
      views::Background::CreateSolidBackground(255, 255, 255));

  WidgetWin::Init(NULL, bounds, true);
  SetContentsView(contents_);

  views::CheckBox* cb =
      new views::CheckBox(L"This is a checkbox");
  contents_->AddChildView(cb);
  // In this fast paced world, who really has time for non hard-coded layout?
  cb->SetBounds(10, 10, 200, 20);
  cb->SetID(kTopCheckBoxID);

  views::View* left_container = new views::View();
  left_container->set_border(
      views::Border::CreateSolidBorder(1, SK_ColorBLACK));
  left_container->set_background(
      views::Background::CreateSolidBackground(240, 240, 240));
  left_container->SetID(kLeftContainerID);
  contents_->AddChildView(left_container);
  left_container->SetBounds(10, 35, 250, 200);

  int label_x = 5;
  int label_width = 50;
  int label_height = 15;
  int text_field_width = 150;
  int y = 10;
  int gap_between_labels = 10;

  views::Label* label = new views::Label(L"Apple:");
  label->SetID(kAppleLabelID);
  left_container->AddChildView(label);
  label->SetBounds(label_x, y, label_width, label_height);

  views::TextField* text_field = new views::TextField();
  text_field->SetID(kAppleTextFieldID);
  left_container->AddChildView(text_field);
  text_field->SetBounds(label_x + label_width + 5, y,
                        text_field_width, label_height);

  y += label_height + gap_between_labels;

  label = new views::Label(L"Orange:");
  label->SetID(kOrangeLabelID);
  left_container->AddChildView(label);
  label->SetBounds(label_x, y, label_width, label_height);

  text_field = new views::TextField();
  text_field->SetID(kOrangeTextFieldID);
  left_container->AddChildView(text_field);
  text_field->SetBounds(label_x + label_width + 5, y,
                        text_field_width, label_height);

  y += label_height + gap_between_labels;

  label = new views::Label(L"Banana:");
  label->SetID(kBananaLabelID);
  left_container->AddChildView(label);
  label->SetBounds(label_x, y, label_width, label_height);

  text_field = new views::TextField();
  text_field->SetID(kBananaTextFieldID);
  left_container->AddChildView(text_field);
  text_field->SetBounds(label_x + label_width + 5, y,
                        text_field_width, label_height);

  y += label_height + gap_between_labels;

  label = new views::Label(L"Kiwi:");
  label->SetID(kKiwiLabelID);
  left_container->AddChildView(label);
  label->SetBounds(label_x, y, label_width, label_height);

  text_field = new views::TextField();
  text_field->SetID(kKiwiTextFieldID);
  left_container->AddChildView(text_field);
  text_field->SetBounds(label_x + label_width + 5, y,
                        text_field_width, label_height);

  y += label_height + gap_between_labels;

  views::NativeButton* button =
      new views::NativeButton(L"Click me");
  button->SetBounds(label_x, y + 10, 50, 20);
  button->SetID(kFruitButtonID);
  left_container->AddChildView(button);
  y += 40;

  cb =  new views::CheckBox(L"This is another check box");
  cb->SetBounds(label_x + label_width + 5, y, 100, 20);
  cb->SetID(kFruitCheckBoxID);
  left_container->AddChildView(cb);

  views::View* right_container = new views::View();
  right_container->set_border(
      views::Border::CreateSolidBorder(1, SK_ColorBLACK));
  right_container->set_background(
      views::Background::CreateSolidBackground(240, 240, 240));
  right_container->SetID(kRightContainerID);
  contents_->AddChildView(right_container);
  right_container->SetBounds(270, 35, 300, 200);

  y = 10;
  int radio_button_height = 15;
  int gap_between_radio_buttons = 10;
  views::View* radio_button =
      new views::RadioButton(L"Asparagus", 1);
  radio_button->SetID(kAsparagusButtonID);
  right_container->AddChildView(radio_button);
  radio_button->SetBounds(5, y, 70, radio_button_height);
  radio_button->SetGroup(1);
  y += radio_button_height + gap_between_radio_buttons;
  radio_button = new views::RadioButton(L"Broccoli", 1);
  radio_button->SetID(kBroccoliButtonID);
  right_container->AddChildView(radio_button);
  radio_button->SetBounds(5, y, 70, radio_button_height);
  radio_button->SetGroup(1);
  y += radio_button_height + gap_between_radio_buttons;
  radio_button = new views::RadioButton(L"Cauliflower", 1);
  radio_button->SetID(kCauliflowerButtonID);
  right_container->AddChildView(radio_button);
  radio_button->SetBounds(5, y, 70, radio_button_height);
  radio_button->SetGroup(1);
  y += radio_button_height + gap_between_radio_buttons;

  views::View* inner_container = new views::View();
  inner_container->set_border(
      views::Border::CreateSolidBorder(1, SK_ColorBLACK));
  inner_container->set_background(
      views::Background::CreateSolidBackground(230, 230, 230));
  inner_container->SetID(kInnerContainerID);
  right_container->AddChildView(inner_container);
  inner_container->SetBounds(100, 10, 150, 180);

  views::ScrollView* scroll_view = new views::ScrollView();
  scroll_view->SetID(kScrollViewID);
  inner_container->AddChildView(scroll_view);
  scroll_view->SetBounds(1, 1, 148, 178);

  views::View* scroll_content = new views::View();
  scroll_content->SetBounds(0, 0, 200, 200);
  scroll_content->set_background(
      views::Background::CreateSolidBackground(200, 200, 200));
  scroll_view->SetContents(scroll_content);

  static const wchar_t* const kTitles[] = {
      L"Rosetta", L"Stupeur et tremblement", L"The diner game",
      L"Ridicule", L"Le placard", L"Les Visiteurs", L"Amelie",
      L"Joyeux Noel", L"Camping", L"Brice de Nice",
      L"Taxi", L"Asterix"
  };

  static const int kIDs[] = {
      kRosettaLinkID, kStupeurEtTremblementLinkID, kDinerGameLinkID,
      kRidiculeLinkID, kClosetLinkID, kVisitingLinkID, kAmelieLinkID,
      kJoyeuxNoelLinkID, kCampingLinkID, kBriceDeNiceLinkID,
      kTaxiLinkID, kAsterixLinkID
  };

  DCHECK(arraysize(kTitles) == arraysize(kIDs));

  y = 5;
  for (int i = 0; i < arraysize(kTitles); ++i) {
    views::Link* link = new views::Link(kTitles[i]);
    link->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
    link->SetID(kIDs[i]);
    scroll_content->AddChildView(link);
    link->SetBounds(5, y, 300, 15);
    y += 15;
  }

  y = 250;
  int width = 50;
  button = new views::NativeButton(L"OK");
  button->SetID(kOKButtonID);

  contents_->AddChildView(button);
  button->SetBounds(150, y, width, 20);

  button = new views::NativeButton(L"Cancel");
  button->SetID(kCancelButtonID);
  contents_->AddChildView(button);
  button->SetBounds(250, y, width, 20);

  button = new views::NativeButton(L"Help");
  button->SetID(kHelpButtonID);
  contents_->AddChildView(button);
  button->SetBounds(350, y, width, 20);

  y += 40;

  // Left bottom box with style checkboxes.
  views::View* contents = new views::View();
  contents->set_background(
      views::Background::CreateSolidBackground(SK_ColorWHITE));
  cb = new views::CheckBox(L"Bold");
  contents->AddChildView(cb);
  cb->SetBounds(10, 10, 50, 20);
  cb->SetID(kBoldCheckBoxID);

  cb = new views::CheckBox(L"Italic");
  contents->AddChildView(cb);
  cb->SetBounds(70, 10, 50, 20);
  cb->SetID(kItalicCheckBoxID);

  cb = new views::CheckBox(L"Underlined");
  contents->AddChildView(cb);
  cb->SetBounds(130, 10, 70, 20);
  cb->SetID(kUnderlinedCheckBoxID);

  style_tab_ = new views::TabbedPane();
  style_tab_->SetID(kStyleContainerID);
  contents_->AddChildView(style_tab_);
  style_tab_->SetBounds(10, y, 210, 50);
  style_tab_->AddTab(L"Style", contents);
  style_tab_->AddTab(L"Other", new views::View());

  // Right bottom box with search.
  contents = new views::View();
  contents->set_background(
      views::Background::CreateSolidBackground(SK_ColorWHITE));
  text_field = new views::TextField();
  contents->AddChildView(text_field);
  text_field->SetBounds(10, 10, 100, 20);
  text_field->SetID(kSearchTextFieldID);

  button = new views::NativeButton(L"Search");
  contents->AddChildView(button);
  button->SetBounds(115, 10, 50, 20);
  button->SetID(kSearchButtonID);

  views::Link* link = new views::Link(L"Help");
  link->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
  link->SetID(kHelpLinkID);
  contents->AddChildView(link);
  link->SetBounds(170, 10, 30, 15);

  search_border_view_ = new BorderView(contents);
  search_border_view_->SetID(kSearchContainerID);

  contents_->AddChildView(search_border_view_);
  search_border_view_->SetBounds(300, y, 200, 50);

  y += 60;

  contents = new views::View();
  contents->SetFocusable(true);
  contents->set_background(
      views::Background::CreateSolidBackground(SK_ColorBLUE));
  contents->SetID(kThumbnailContainerID);
  button = new views::NativeButton(L"Star");
  contents->AddChildView(button);
  button->SetBounds(5, 5, 50, 20);
  button->SetID(kThumbnailStarID);
  button = new views::NativeButton(L"SuperStar");
  contents->AddChildView(button);
  button->SetBounds(60, 5, 100, 20);
  button->SetID(kThumbnailSuperStarID);

  contents_->AddChildView(contents);
  contents->SetBounds(200, y, 200, 50);
}

////////////////////////////////////////////////////////////////////////////////
// FocusManagerTest
////////////////////////////////////////////////////////////////////////////////

FocusManagerTest::FocusManagerTest() {
}

FocusManagerTest::~FocusManagerTest() {
}

TestViewWindow* FocusManagerTest::GetWindow() {
  return test_window_;
}

void FocusManagerTest::SetUp() {
  OleInitialize(NULL);
  test_window_ = new TestViewWindow(this);
  test_window_->Init();
  ShowWindow(test_window_->GetHWND(), SW_SHOW);
}

void FocusManagerTest::TearDown() {
  test_window_->CloseNow();

  // Flush the message loop to make Purify happy.
  message_loop_.RunAllPending();
  OleUninitialize();
}

////////////////////////////////////////////////////////////////////////////////
// The tests
////////////////////////////////////////////////////////////////////////////////


TEST_F(FocusManagerTest, NormalTraversal) {
  const int kTraversalIDs[] = { kTopCheckBoxID,  kAppleTextFieldID,
      kOrangeTextFieldID, kBananaTextFieldID, kKiwiTextFieldID,
      kFruitButtonID, kFruitCheckBoxID, kAsparagusButtonID, kRosettaLinkID,
      kStupeurEtTremblementLinkID,
      kDinerGameLinkID, kRidiculeLinkID, kClosetLinkID, kVisitingLinkID,
      kAmelieLinkID, kJoyeuxNoelLinkID, kCampingLinkID, kBriceDeNiceLinkID,
      kTaxiLinkID, kAsterixLinkID, kOKButtonID, kCancelButtonID, kHelpButtonID,
      kStyleContainerID, kBoldCheckBoxID, kItalicCheckBoxID,
      kUnderlinedCheckBoxID, kSearchTextFieldID, kSearchButtonID, kHelpLinkID,
      kThumbnailContainerID, kThumbnailStarID, kThumbnailSuperStarID };

  // Uncomment the following line if you want to test manually the UI of this
  // test.
  // MessageLoop::current()->Run(new views::AcceleratorHandler());

  views::FocusManager* focus_manager =
      views::FocusManager::GetFocusManager(test_window_->GetHWND());
  // Let's traverse the whole focus hierarchy (several times, to make sure it
  // loops OK).
  focus_manager->SetFocusedView(NULL);
  for (int i = 0; i < 3; ++i) {
    for (int j = 0; j < arraysize(kTraversalIDs); j++) {
      focus_manager->AdvanceFocus(false);
      views::View* focused_view = focus_manager->GetFocusedView();
      EXPECT_TRUE(focused_view != NULL);
      if (focused_view)
        EXPECT_EQ(kTraversalIDs[j], focused_view->GetID());
    }
  }

  // Focus the 1st item.
  views::RootView* root_view = test_window_->GetContentsRootView();
  focus_manager->SetFocusedView(root_view->GetViewByID(kTraversalIDs[0]));

  /* BROKEN because of bug #1153276.  The reverse order of traversal in Tabbed
     Panes is broken (we go to the tab before going to the content
  // Let's traverse in reverse order.
  for (int i = 0; i < 3; ++i) {
    for (int j = arraysize(kTraversalIDs) - 1; j >= 0; --j) {
      focus_manager->AdvanceFocus(true);
      views::View* focused_view = focus_manager->GetFocusedView();
      EXPECT_TRUE(focused_view != NULL);
      if (focused_view)
        EXPECT_EQ(kTraversalIDs[j], focused_view->GetID());
    }
  }
  */
}

TEST_F(FocusManagerTest, TraversalWithNonEnabledViews) {
  const int kMainContentsDisabledIDs[] = {
      kBananaTextFieldID, kFruitCheckBoxID, kAsparagusButtonID,
      kCauliflowerButtonID, kClosetLinkID, kVisitingLinkID, kBriceDeNiceLinkID,
      kTaxiLinkID, kAsterixLinkID, kHelpButtonID };

  const int kStyleContentsDisabledIDs[] = { kBoldCheckBoxID };

  const int kSearchContentsDisabledIDs[] = { kSearchTextFieldID, kHelpLinkID };

  const int kTraversalIDs[] = { kTopCheckBoxID,  kAppleTextFieldID,
      kOrangeTextFieldID, kKiwiTextFieldID, kFruitButtonID, kBroccoliButtonID,
      kRosettaLinkID, kStupeurEtTremblementLinkID, kDinerGameLinkID,
      kRidiculeLinkID, kAmelieLinkID, kJoyeuxNoelLinkID, kCampingLinkID,
      kOKButtonID, kCancelButtonID, kStyleContainerID,
      kItalicCheckBoxID, kUnderlinedCheckBoxID, kSearchButtonID,
      kThumbnailContainerID, kThumbnailStarID, kThumbnailSuperStarID };

  // Let's disable some views.
  views::RootView* root_view = test_window_->GetContentsRootView();
  for (int i = 0; i < arraysize(kMainContentsDisabledIDs); i++) {
    views::View* v = root_view->GetViewByID(kMainContentsDisabledIDs[i]);
    ASSERT_TRUE(v != NULL);
    if (v)
      v->SetEnabled(false);
  }
  root_view = test_window_->GetStyleRootView();
  for (int i = 0; i < arraysize(kStyleContentsDisabledIDs); i++) {
    views::View* v = root_view->GetViewByID(kStyleContentsDisabledIDs[i]);
    ASSERT_TRUE(v != NULL);
    if (v)
      v->SetEnabled(false);
  }
  root_view = test_window_->GetSearchRootView();
  for (int i = 0; i < arraysize(kSearchContentsDisabledIDs); i++) {
    views::View* v =
        root_view->GetViewByID(kSearchContentsDisabledIDs[i]);
    ASSERT_TRUE(v != NULL);
    if (v)
      v->SetEnabled(false);
  }


  views::FocusManager* focus_manager =
      views::FocusManager::GetFocusManager(test_window_->GetHWND());
  views::View* focused_view;
  // Let's do one traversal (several times, to make sure it loops ok).
  for (int i = 0; i < 3;++i) {
    for (int j = 0; j < arraysize(kTraversalIDs); j++) {
      focus_manager->AdvanceFocus(false);
      focused_view = focus_manager->GetFocusedView();
      EXPECT_TRUE(focused_view != NULL);
      if (focused_view)
        EXPECT_EQ(kTraversalIDs[j], focused_view->GetID());
    }
  }

  // Focus the 1st item.
  focus_manager->AdvanceFocus(false);
  focused_view = focus_manager->GetFocusedView();
  EXPECT_TRUE(focused_view != NULL);
  if (focused_view)
    EXPECT_EQ(kTraversalIDs[0], focused_view->GetID());

  // Same thing in reverse.
  /* BROKEN because of bug #1153276.  The reverse order of traversal in Tabbed
  Panes is broken (we go to the tab before going to the content

  for (int i = 0; i < 3; ++i) {
    for (int j = arraysize(kTraversalIDs) - 1; j >= 0; --j) {
      focus_manager->AdvanceFocus(true);
      focused_view = focus_manager->GetFocusedView();
      EXPECT_TRUE(focused_view != NULL);
      if (focused_view)
        EXPECT_EQ(kTraversalIDs[j], focused_view->GetID());
    }
  }
  */
}

}