OLD | NEW |
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 "ash/launcher/launcher_view.h" | 5 #include "ash/launcher/launcher_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "ash/ash_switches.h" | 10 #include "ash/ash_switches.h" |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 } | 317 } |
318 } | 318 } |
319 | 319 |
320 views::View* SimulateButtonPressed( | 320 views::View* SimulateButtonPressed( |
321 internal::LauncherButtonHost::Pointer pointer, | 321 internal::LauncherButtonHost::Pointer pointer, |
322 int button_index) { | 322 int button_index) { |
323 internal::LauncherButtonHost* button_host = launcher_view_; | 323 internal::LauncherButtonHost* button_host = launcher_view_; |
324 views::View* button = test_api_->GetButton(button_index); | 324 views::View* button = test_api_->GetButton(button_index); |
325 ui::MouseEvent click_event(ui::ET_MOUSE_PRESSED, | 325 ui::MouseEvent click_event(ui::ET_MOUSE_PRESSED, |
326 button->bounds().origin(), | 326 button->bounds().origin(), |
327 button->bounds().origin(), 0); | 327 button->GetBoundsInScreen().origin(), 0); |
328 button_host->PointerPressedOnButton(button, pointer, click_event); | 328 button_host->PointerPressedOnButton(button, pointer, click_event); |
329 return button; | 329 return button; |
330 } | 330 } |
331 | 331 |
332 views::View* SimulateClick(internal::LauncherButtonHost::Pointer pointer, | 332 views::View* SimulateClick(internal::LauncherButtonHost::Pointer pointer, |
333 int button_index) { | 333 int button_index) { |
334 internal::LauncherButtonHost* button_host = launcher_view_; | 334 internal::LauncherButtonHost* button_host = launcher_view_; |
335 views::View* button = SimulateButtonPressed(pointer, button_index); | 335 views::View* button = SimulateButtonPressed(pointer, button_index); |
336 button_host->PointerReleasedOnButton(button, | 336 button_host->PointerReleasedOnButton(button, |
337 internal::LauncherButtonHost::MOUSE, | 337 internal::LauncherButtonHost::MOUSE, |
338 false); | 338 false); |
339 return button; | 339 return button; |
340 } | 340 } |
341 | 341 |
342 views::View* SimulateDrag(internal::LauncherButtonHost::Pointer pointer, | 342 views::View* SimulateDrag(internal::LauncherButtonHost::Pointer pointer, |
343 int button_index, | 343 int button_index, |
344 int destination_index) { | 344 int destination_index) { |
345 internal::LauncherButtonHost* button_host = launcher_view_; | 345 internal::LauncherButtonHost* button_host = launcher_view_; |
346 views::View* button = SimulateButtonPressed(pointer, button_index); | 346 views::View* button = SimulateButtonPressed(pointer, button_index); |
347 | 347 |
348 // Drag. | 348 // Drag. |
349 views::View* destination = test_api_->GetButton(destination_index); | 349 views::View* destination = test_api_->GetButton(destination_index); |
350 ui::MouseEvent drag_event(ui::ET_MOUSE_DRAGGED, | 350 ui::MouseEvent drag_event(ui::ET_MOUSE_DRAGGED, |
351 destination->bounds().origin(), | 351 destination->bounds().origin(), |
352 destination->bounds().origin(), 0); | 352 destination->GetBoundsInScreen().origin(), 0); |
353 button_host->PointerDraggedOnButton(button, pointer, drag_event); | 353 button_host->PointerDraggedOnButton(button, pointer, drag_event); |
354 return button; | 354 return button; |
355 } | 355 } |
356 | 356 |
357 void SetupForDragTest( | 357 void SetupForDragTest( |
358 std::vector<std::pair<LauncherID, views::View*> >* id_map) { | 358 std::vector<std::pair<LauncherID, views::View*> >* id_map) { |
359 // Initialize |id_map| with the automatically-created launcher buttons. | 359 // Initialize |id_map| with the automatically-created launcher buttons. |
360 for (size_t i = 0; i < model_->items().size(); ++i) { | 360 for (size_t i = 0; i < model_->items().size(); ++i) { |
361 internal::LauncherButton* button = test_api_->GetButton(i); | 361 internal::LauncherButton* button = test_api_->GetButton(i); |
362 id_map->push_back(std::make_pair(model_->items()[i].id, button)); | 362 id_map->push_back(std::make_pair(model_->items()[i].id, button)); |
(...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1116 test_api_->GetButtonCount()); | 1116 test_api_->GetButtonCount()); |
1117 gfx::Rect ideal_bounds_0 = test_api_->GetIdealBoundsByIndex(0); | 1117 gfx::Rect ideal_bounds_0 = test_api_->GetIdealBoundsByIndex(0); |
1118 gfx::Rect ideal_bounds_1 = test_api_->GetIdealBoundsByIndex(1); | 1118 gfx::Rect ideal_bounds_1 = test_api_->GetIdealBoundsByIndex(1); |
1119 EXPECT_GT(ideal_bounds_0.width(), ideal_bounds_1.width()); | 1119 EXPECT_GT(ideal_bounds_0.width(), ideal_bounds_1.width()); |
1120 } | 1120 } |
1121 | 1121 |
1122 INSTANTIATE_TEST_CASE_P(LtrRtl, LauncherViewTextDirectionTest, testing::Bool()); | 1122 INSTANTIATE_TEST_CASE_P(LtrRtl, LauncherViewTextDirectionTest, testing::Bool()); |
1123 | 1123 |
1124 } // namespace test | 1124 } // namespace test |
1125 } // namespace ash | 1125 } // namespace ash |
OLD | NEW |