Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(106)

Side by Side Diff: ui/views/animation/ink_drop_impl_unittest.cc

Issue 2642173002: Migrate GCMKeyStore and InkDropImpl tests to use EXPECT_DCHECK_DEATH. (Closed)
Patch Set: Remove static_assert()s Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/gcm_driver/crypto/gcm_key_store_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/gtest_util.h"
11 #include "base/test/test_simple_task_runner.h" 12 #include "base/test/test_simple_task_runner.h"
12 #include "base/threading/thread_task_runner_handle.h" 13 #include "base/threading/thread_task_runner_handle.h"
13 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
14 #include "ui/compositor/scoped_animation_duration_scale_mode.h" 15 #include "ui/compositor/scoped_animation_duration_scale_mode.h"
15 #include "ui/views/animation/test/ink_drop_impl_test_api.h" 16 #include "ui/views/animation/test/ink_drop_impl_test_api.h"
16 #include "ui/views/animation/test/test_ink_drop_host.h" 17 #include "ui/views/animation/test/test_ink_drop_host.h"
17 #include "ui/views/test/views_test_base.h" 18 #include "ui/views/test/views_test_base.h"
18 19
19 namespace views { 20 namespace views {
20 21
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 226
226 test_api()->CompleteAnimations(); 227 test_api()->CompleteAnimations();
227 228
228 ink_drop()->SetHovered(false); 229 ink_drop()->SetHovered(false);
229 EXPECT_TRUE(AreLayersAddedToHost()); 230 EXPECT_TRUE(AreLayersAddedToHost());
230 231
231 ink_drop()->SetHovered(true); 232 ink_drop()->SetHovered(true);
232 EXPECT_TRUE(AreLayersAddedToHost()); 233 EXPECT_TRUE(AreLayersAddedToHost());
233 } 234 }
234 235
235 #if DCHECK_IS_ON()
236 TEST_F(InkDropImplTest, 236 TEST_F(InkDropImplTest,
237 SettingHighlightStateDuringStateExitIsntAllowedDeathTest) { 237 SettingHighlightStateDuringStateExitIsntAllowedDeathTest) {
238 ::testing::FLAGS_gtest_death_test_style = "threadsafe"; 238 ::testing::FLAGS_gtest_death_test_style = "threadsafe";
239 239
240 test::InkDropImplTestApi::SetStateOnExitHighlightState::Install( 240 test::InkDropImplTestApi::SetStateOnExitHighlightState::Install(
241 test_api()->state_factory()); 241 test_api()->state_factory());
242 ASSERT_DEATH_IF_SUPPORTED( 242 EXPECT_DCHECK_DEATH(
243 test::InkDropImplTestApi::AccessFactoryOnExitHighlightState::Install( 243 test::InkDropImplTestApi::AccessFactoryOnExitHighlightState::Install(
244 test_api()->state_factory()), 244 test_api()->state_factory()));
245 ".*HighlightStates should not be changed within a call to "
246 "HighlightState::Exit\\(\\)\\..*");
247 // Need to set the |highlight_state_| directly because the 245 // Need to set the |highlight_state_| directly because the
248 // SetStateOnExitHighlightState will recursively try to set it during tear 246 // SetStateOnExitHighlightState will recursively try to set it during tear
249 // down and cause a stack overflow. 247 // down and cause a stack overflow.
250 test_api()->SetHighlightState(nullptr); 248 test_api()->SetHighlightState(nullptr);
251 } 249 }
252 #endif
253 250
254 // Verifies there is no use after free errors. 251 // Verifies there is no use after free errors.
255 TEST_F(InkDropImplTest, 252 TEST_F(InkDropImplTest,
256 TearingDownHighlightStateThatAccessesTheStateFactoryIsSafe) { 253 TearingDownHighlightStateThatAccessesTheStateFactoryIsSafe) {
257 test::InkDropImplTestApi::AccessFactoryOnExitHighlightState::Install( 254 test::InkDropImplTestApi::AccessFactoryOnExitHighlightState::Install(
258 test_api()->state_factory()); 255 test_api()->state_factory());
259 test::InkDropImplTestApi::AccessFactoryOnExitHighlightState::Install( 256 test::InkDropImplTestApi::AccessFactoryOnExitHighlightState::Install(
260 test_api()->state_factory()); 257 test_api()->state_factory());
261 } 258 }
262 259
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 EXPECT_TRUE(test_api()->IsHighlightFadingInOrVisible()); 560 EXPECT_TRUE(test_api()->IsHighlightFadingInOrVisible());
564 561
565 ink_drop()->SetHovered(false); 562 ink_drop()->SetHovered(false);
566 ink_drop()->SetFocused(false); 563 ink_drop()->SetFocused(false);
567 564
568 EXPECT_TRUE(test_api()->IsHighlightFadingInOrVisible()); 565 EXPECT_TRUE(test_api()->IsHighlightFadingInOrVisible());
569 EXPECT_FALSE(test_api()->ShouldHighlight()); 566 EXPECT_FALSE(test_api()->ShouldHighlight());
570 } 567 }
571 568
572 } // namespace views 569 } // namespace views
OLDNEW
« no previous file with comments | « components/gcm_driver/crypto/gcm_key_store_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698