• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
3 // found in the LICENSE file.
4 
5 #include "ui/app_list/views/test/apps_grid_view_test_api.h"
6 
7 #include "ui/app_list/views/app_list_item_view.h"
8 #include "ui/app_list/views/apps_grid_view.h"
9 #include "ui/events/event.h"
10 
11 namespace app_list {
12 namespace test {
13 
AppsGridViewTestApi(AppsGridView * view)14 AppsGridViewTestApi::AppsGridViewTestApi(AppsGridView* view)
15     : view_(view) {
16 }
17 
~AppsGridViewTestApi()18 AppsGridViewTestApi::~AppsGridViewTestApi() {
19 }
20 
GetViewAtModelIndex(int index) const21 views::View* AppsGridViewTestApi::GetViewAtModelIndex(int index) const {
22   return view_->view_model_.view_at(index);
23 }
24 
LayoutToIdealBounds()25 void AppsGridViewTestApi::LayoutToIdealBounds() {
26   view_->bounds_animator_.Cancel();
27   view_->Layout();
28 }
29 
SetPageFlipDelay(int page_flip_delay_in_ms)30 void AppsGridViewTestApi::SetPageFlipDelay(int page_flip_delay_in_ms) {
31   view_->page_flip_delay_in_ms_ = page_flip_delay_in_ms;
32 }
33 
PressItemAt(int index)34 void AppsGridViewTestApi::PressItemAt(int index) {
35   GetViewAtModelIndex(index)->OnKeyPressed(
36       ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_RETURN, 0, false));
37 }
38 
DisableSynchronousDrag()39 void AppsGridViewTestApi::DisableSynchronousDrag() {
40 #if defined(OS_WIN)
41   DCHECK(view_->synchronous_drag_ == NULL) << "DisableSynchronousDrag needs to "
42                                               "be called before "
43                                               "synchronous_drag_ is set up.";
44   view_->use_synchronous_drag_ = false;
45 #endif
46 }
47 
HasPendingPageFlip() const48 bool AppsGridViewTestApi::HasPendingPageFlip() const {
49   return view_->page_flip_timer_.IsRunning() ||
50          view_->pagination_model()->has_transition();
51 }
52 
53 }  // namespace test
54 }  // namespace app_list
55