| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 <memory> | 5 #include <memory> |
| 6 | 6 |
| 7 #include "ui/views/animation/ink_drop_impl.h" | 7 #include "ui/views/animation/ink_drop_impl.h" |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| 11 #include "base/test/test_simple_task_runner.h" | 11 #include "base/test/test_simple_task_runner.h" |
| 12 #include "base/threading/thread_task_runner_handle.h" | 12 #include "base/threading/thread_task_runner_handle.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 14 #include "ui/compositor/scoped_animation_duration_scale_mode.h" | 14 #include "ui/compositor/scoped_animation_duration_scale_mode.h" |
| 15 #include "ui/views/animation/test/ink_drop_impl_test_api.h" | 15 #include "ui/views/animation/test/ink_drop_impl_test_api.h" |
| 16 #include "ui/views/animation/test/test_ink_drop_host.h" | 16 #include "ui/views/animation/test/test_ink_drop_host.h" |
| 17 #include "ui/views/test/views_test_base.h" |
| 17 | 18 |
| 18 namespace views { | 19 namespace views { |
| 19 | 20 |
| 20 // NOTE: The InkDropImpl class is also tested by the InkDropFactoryTest tests. | 21 // NOTE: The InkDropImpl class is also tested by the InkDropFactoryTest tests. |
| 21 class InkDropImplTest : public testing::Test { | 22 class InkDropImplTest : public testing::Test { |
| 22 public: | 23 public: |
| 23 InkDropImplTest(); | 24 InkDropImplTest(); |
| 24 ~InkDropImplTest() override; | 25 ~InkDropImplTest() override; |
| 25 | 26 |
| 26 protected: | 27 protected: |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 | 227 |
| 227 ink_drop()->SetHovered(false); | 228 ink_drop()->SetHovered(false); |
| 228 EXPECT_TRUE(AreLayersAddedToHost()); | 229 EXPECT_TRUE(AreLayersAddedToHost()); |
| 229 | 230 |
| 230 ink_drop()->SetHovered(true); | 231 ink_drop()->SetHovered(true); |
| 231 EXPECT_TRUE(AreLayersAddedToHost()); | 232 EXPECT_TRUE(AreLayersAddedToHost()); |
| 232 } | 233 } |
| 233 | 234 |
| 234 #if DCHECK_IS_ON() | 235 #if DCHECK_IS_ON() |
| 235 TEST_F(InkDropImplTest, SettingHighlightStateDuringStateExitIsntAllowed) { | 236 TEST_F(InkDropImplTest, SettingHighlightStateDuringStateExitIsntAllowed) { |
| 237 // This test uses a death assert, which works by forking the process. That |
| 238 // doesn't work well with mus. |
| 239 if (ViewsTestBase::IsAuraMusClient() || ViewsTestBase::IsMus()) |
| 240 return; |
| 241 |
| 236 test::InkDropImplTestApi::SetStateOnExitHighlightState::Install( | 242 test::InkDropImplTestApi::SetStateOnExitHighlightState::Install( |
| 237 test_api()->state_factory()); | 243 test_api()->state_factory()); |
| 238 ASSERT_DEATH_IF_SUPPORTED( | 244 ASSERT_DEATH_IF_SUPPORTED( |
| 239 test::InkDropImplTestApi::AccessFactoryOnExitHighlightState::Install( | 245 test::InkDropImplTestApi::AccessFactoryOnExitHighlightState::Install( |
| 240 test_api()->state_factory()), | 246 test_api()->state_factory()), |
| 241 ".*HighlightStates should not be changed within a call to " | 247 ".*HighlightStates should not be changed within a call to " |
| 242 "HighlightState::Exit\\(\\)\\..*"); | 248 "HighlightState::Exit\\(\\)\\..*"); |
| 243 // Need to set the |highlight_state_| directly because the | 249 // Need to set the |highlight_state_| directly because the |
| 244 // SetStateOnExitHighlightState will recursively try to set it during tear | 250 // SetStateOnExitHighlightState will recursively try to set it during tear |
| 245 // down and cause a stack overflow. | 251 // down and cause a stack overflow. |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 559 EXPECT_TRUE(test_api()->IsHighlightFadingInOrVisible()); | 565 EXPECT_TRUE(test_api()->IsHighlightFadingInOrVisible()); |
| 560 | 566 |
| 561 ink_drop()->SetHovered(false); | 567 ink_drop()->SetHovered(false); |
| 562 ink_drop()->SetFocused(false); | 568 ink_drop()->SetFocused(false); |
| 563 | 569 |
| 564 EXPECT_TRUE(test_api()->IsHighlightFadingInOrVisible()); | 570 EXPECT_TRUE(test_api()->IsHighlightFadingInOrVisible()); |
| 565 EXPECT_FALSE(test_api()->ShouldHighlight()); | 571 EXPECT_FALSE(test_api()->ShouldHighlight()); |
| 566 } | 572 } |
| 567 | 573 |
| 568 } // namespace views | 574 } // namespace views |
| OLD | NEW |