| 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/common/shelf/shelf_view.h" | 5 #include "ash/common/shelf/shelf_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 #include "ash/common/test/test_system_tray_delegate.h" | 26 #include "ash/common/test/test_system_tray_delegate.h" |
| 27 #include "ash/common/wm_shell.h" | 27 #include "ash/common/wm_shell.h" |
| 28 #include "ash/common/wm_window.h" | 28 #include "ash/common/wm_window.h" |
| 29 #include "ash/public/cpp/shell_window_ids.h" | 29 #include "ash/public/cpp/shell_window_ids.h" |
| 30 #include "ash/root_window_controller.h" | 30 #include "ash/root_window_controller.h" |
| 31 #include "ash/shell.h" | 31 #include "ash/shell.h" |
| 32 #include "ash/test/ash_test_base.h" | 32 #include "ash/test/ash_test_base.h" |
| 33 #include "ash/test/ash_test_helper.h" | 33 #include "ash/test/ash_test_helper.h" |
| 34 #include "ash/test/overflow_bubble_view_test_api.h" | 34 #include "ash/test/overflow_bubble_view_test_api.h" |
| 35 #include "ash/test/shelf_view_test_api.h" | 35 #include "ash/test/shelf_view_test_api.h" |
| 36 #include "ash/test/shell_test_api.h" |
| 36 #include "ash/test/test_shell_delegate.h" | 37 #include "ash/test/test_shell_delegate.h" |
| 37 #include "base/i18n/rtl.h" | 38 #include "base/i18n/rtl.h" |
| 38 #include "base/macros.h" | 39 #include "base/macros.h" |
| 39 #include "base/memory/ptr_util.h" | 40 #include "base/memory/ptr_util.h" |
| 40 #include "base/numerics/safe_conversions.h" | 41 #include "base/numerics/safe_conversions.h" |
| 41 #include "base/run_loop.h" | 42 #include "base/run_loop.h" |
| 42 #include "base/strings/string_number_conversions.h" | 43 #include "base/strings/string_number_conversions.h" |
| 43 #include "base/strings/utf_string_conversions.h" | 44 #include "base/strings/utf_string_conversions.h" |
| 44 #include "base/test/histogram_tester.h" | 45 #include "base/test/histogram_tester.h" |
| 45 #include "base/test/scoped_mock_time_message_loop_task_runner.h" | 46 #include "base/test/scoped_mock_time_message_loop_task_runner.h" |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 class ShelfViewTest : public AshTestBase { | 294 class ShelfViewTest : public AshTestBase { |
| 294 public: | 295 public: |
| 295 static const char* | 296 static const char* |
| 296 kTimeBetweenWindowMinimizedAndActivatedActionsHistogramName; | 297 kTimeBetweenWindowMinimizedAndActivatedActionsHistogramName; |
| 297 | 298 |
| 298 ShelfViewTest() : model_(nullptr), shelf_view_(nullptr), browser_index_(1) {} | 299 ShelfViewTest() : model_(nullptr), shelf_view_(nullptr), browser_index_(1) {} |
| 299 ~ShelfViewTest() override {} | 300 ~ShelfViewTest() override {} |
| 300 | 301 |
| 301 void SetUp() override { | 302 void SetUp() override { |
| 302 AshTestBase::SetUp(); | 303 AshTestBase::SetUp(); |
| 303 model_ = WmShell::Get()->shelf_model(); | 304 model_ = Shell::Get()->shelf_model(); |
| 304 shelf_view_ = GetPrimaryShelf()->GetShelfViewForTesting(); | 305 shelf_view_ = GetPrimaryShelf()->GetShelfViewForTesting(); |
| 305 | 306 |
| 306 WebNotificationTray::DisableAnimationsForTest(true); | 307 WebNotificationTray::DisableAnimationsForTest(true); |
| 307 | 308 |
| 308 // The bounds should be big enough for 4 buttons + overflow chevron. | 309 // The bounds should be big enough for 4 buttons + overflow chevron. |
| 309 shelf_view_->SetBounds(0, 0, 500, GetShelfConstant(SHELF_SIZE)); | 310 shelf_view_->SetBounds(0, 0, 500, GetShelfConstant(SHELF_SIZE)); |
| 310 | 311 |
| 311 test_api_.reset(new ShelfViewTestAPI(shelf_view_)); | 312 test_api_.reset(new ShelfViewTestAPI(shelf_view_)); |
| 312 test_api_->SetAnimationDuration(1); // Speeds up animation for test. | 313 test_api_->SetAnimationDuration(1); // Speeds up animation for test. |
| 313 | 314 |
| (...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 676 } | 677 } |
| 677 | 678 |
| 678 // Returns the item's ShelfID at |index|. | 679 // Returns the item's ShelfID at |index|. |
| 679 ShelfID GetItemId(int index) { | 680 ShelfID GetItemId(int index) { |
| 680 DCHECK_GE(index, 0); | 681 DCHECK_GE(index, 0); |
| 681 return model_->items()[index].id; | 682 return model_->items()[index].id; |
| 682 } | 683 } |
| 683 | 684 |
| 684 void ReplaceShelfDelegate() { | 685 void ReplaceShelfDelegate() { |
| 685 // Clear the value first to avoid TestShelfDelegate's singleton check. | 686 // Clear the value first to avoid TestShelfDelegate's singleton check. |
| 686 WmShell::Get()->SetShelfDelegateForTesting(nullptr); | 687 test::ShellTestApi().SetShelfDelegate(nullptr); |
| 687 shelf_delegate_ = new TestShelfDelegateForShelfView(); | 688 shelf_delegate_ = new TestShelfDelegateForShelfView(); |
| 688 test_api_->SetShelfDelegate(shelf_delegate_); | 689 test_api_->SetShelfDelegate(shelf_delegate_); |
| 689 WmShell::Get()->SetShelfDelegateForTesting( | 690 test::ShellTestApi().SetShelfDelegate(base::WrapUnique(shelf_delegate_)); |
| 690 base::WrapUnique(shelf_delegate_)); | |
| 691 } | 691 } |
| 692 | 692 |
| 693 ShelfModel* model_; | 693 ShelfModel* model_; |
| 694 ShelfView* shelf_view_; | 694 ShelfView* shelf_view_; |
| 695 int browser_index_; | 695 int browser_index_; |
| 696 | 696 |
| 697 // Owned by ash::WmShell. | 697 // Owned by ash::WmShell. |
| 698 TestShelfDelegateForShelfView* shelf_delegate_; | 698 TestShelfDelegateForShelfView* shelf_delegate_; |
| 699 | 699 |
| 700 std::unique_ptr<ShelfViewTestAPI> test_api_; | 700 std::unique_ptr<ShelfViewTestAPI> test_api_; |
| (...skipping 2311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3012 EXPECT_EQ(views::InkDropState::ACTIVATED, | 3012 EXPECT_EQ(views::InkDropState::ACTIVATED, |
| 3013 overflow_button_ink_drop_->GetTargetInkDropState()); | 3013 overflow_button_ink_drop_->GetTargetInkDropState()); |
| 3014 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), | 3014 EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(), |
| 3015 IsEmpty()); | 3015 IsEmpty()); |
| 3016 | 3016 |
| 3017 ASSERT_TRUE(test_api_->IsShowingOverflowBubble()); | 3017 ASSERT_TRUE(test_api_->IsShowingOverflowBubble()); |
| 3018 } | 3018 } |
| 3019 | 3019 |
| 3020 } // namespace test | 3020 } // namespace test |
| 3021 } // namespace ash | 3021 } // namespace ash |
| OLD | NEW |