~hikiko/nux/arb-srgba-shader

« back to all changes in this revision

Viewing changes to tests/xtest-hgrid-key-navigation.cpp

  • Committer: Tarmac
  • Author(s): Andrea Azzarone
  • Date: 2012-08-01 21:03:08 UTC
  • mfrom: (637.3.2 improve-key-nav)
  • Revision ID: tarmac-20120801210308-ymwl0t3rash4eri2
Fix bottom-up keynavigation in GridHLayout.. Fixes: . Approved by Jay Taoko.

Show diffs side-by-side

added added

removed removed

Lines of Context:
42
42
  
43
43
  nux::TestView* CreateTile();
44
44
  void AddTile(nux::TestView* tile);
45
 
  
 
45
 
 
46
  nux::VLayout* vlayout_;
46
47
  nux::GridHLayout* grid_layout_;
47
48
  nux::TestView* tiles_[11];
 
49
  nux::TestView* bottom_view_;
48
50
};
49
51
 
50
52
HGridKeyNavigationTest::HGridKeyNavigationTest(const char* program_name,
71
73
}
72
74
 
73
75
void HGridKeyNavigationTest::UserInterfaceSetup()
74
 
{  
 
76
{
 
77
  vlayout_ = new nux::VLayout(NUX_TRACKER_LOCATION);
 
78
 
75
79
  grid_layout_ = new nux::GridHLayout(NUX_TRACKER_LOCATION);
76
80
  grid_layout_->ForceChildrenSize(true);
77
81
  grid_layout_->SetChildrenSize(100, 100);
78
82
  grid_layout_->EnablePartialVisibility(false);
79
83
  grid_layout_->SetPadding(20, 20);
80
84
  grid_layout_->SetSpaceBetweenChildren(10, 10);
 
85
  vlayout_->AddLayout(grid_layout_);
81
86
  
82
87
  for (int i=0; i<11; ++i)
83
88
  {
84
89
    tiles_[i] = CreateTile();
85
90
    AddTile(tiles_[i]);
86
91
  }
87
 
  
88
 
  nux::GetWindowCompositor().SetKeyFocusArea(tiles_[0]);
89
 
  
90
 
  static_cast<nux::WindowThread*>(window_thread_)->SetLayout(grid_layout_);
 
92
 
 
93
  bottom_view_ = CreateTile();
 
94
  vlayout_->AddView(bottom_view_);
 
95
 
 
96
  nux::GetWindowCompositor().SetKeyFocusArea(bottom_view_);
 
97
  
 
98
  static_cast<nux::WindowThread*>(window_thread_)->SetLayout(vlayout_);
91
99
  
92
100
  nux::ColorLayer background(nux::Color(0xFF4D4D4D));
93
101
  static_cast<nux::WindowThread*>(window_thread_)->SetWindowBackgroundPaintLayer(&background);
115
123
  test.PutMouseAt(0, 0);
116
124
 
117
125
  test.TestReportMsg(key_navigation_test->grid_layout_, "TestView created");
118
 
  test.TestReportMsg(key_navigation_test->tiles_[0]->has_focus_, "Top left tile has key focus");
119
 
 
 
126
  test.TestReportMsg(key_navigation_test->bottom_view_->has_focus_, "bottom_view has key focus");
 
127
 
 
128
  // Up key, must focus (last row, first column) item
 
129
  test.SendFakeKeyEvent(XK_Up, 0);
 
130
  nux::SleepForMilliseconds(500);
 
131
  test.TestReportMsg(key_navigation_test->tiles_[8]->has_focus_, "KEY_NAV_UP test");
 
132
 
 
133
  key_navigation_test->bottom_view_->can_focus_ = false;
 
134
  for (int i = 0; i < 2; ++i)
 
135
    test.SendFakeKeyEvent(XK_Up, 0);
 
136
  nux::SleepForMilliseconds(500);
120
137
 
121
138
  // Rigth key
122
139
  for (int i=0; i<3; ++i)
169
186
    test.TestReportMsg(key_navigation_test->tiles_[4*(i-1)]->has_focus_, "Up: key focus in");
170
187
  }
171
188
  
172
 
  // Another down key, should do nothing
 
189
  // Another up key, should do nothing
173
190
  test.SendFakeKeyEvent(XK_Up, 0);
174
191
  nux::SleepForMilliseconds(500);
175
192
  test.TestReportMsg(key_navigation_test->tiles_[0]->has_focus_, "Up key, first row");