| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 // Tests of CancellationFlag class. | 5 // Tests of CancellationFlag class. |
| 6 | 6 |
| 7 #include "base/cancellation_flag.h" | 7 #include "base/cancellation_flag.h" |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/spin_wait.h" | 10 #include "base/spin_wait.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 | 42 |
| 43 TEST(CancellationFlagTest, DoubleSetTest) { | 43 TEST(CancellationFlagTest, DoubleSetTest) { |
| 44 CancellationFlag flag; | 44 CancellationFlag flag; |
| 45 ASSERT_FALSE(flag.IsSet()); | 45 ASSERT_FALSE(flag.IsSet()); |
| 46 flag.Set(); | 46 flag.Set(); |
| 47 ASSERT_TRUE(flag.IsSet()); | 47 ASSERT_TRUE(flag.IsSet()); |
| 48 flag.Set(); | 48 flag.Set(); |
| 49 ASSERT_TRUE(flag.IsSet()); | 49 ASSERT_TRUE(flag.IsSet()); |
| 50 } | 50 } |
| 51 | 51 |
| 52 #if defined(OS_WIN) | 52 TEST(CancellationFlagTest, SetOnDifferentThreadDeathTest) { |
| 53 #define DISABLED_ON_WIN(x) DISABLED_##x | |
| 54 #else | |
| 55 #define DISABLED_ON_WIN(x) x | |
| 56 #endif | |
| 57 | |
| 58 // CancellationFlag should die on a DCHECK if Set() is called from | |
| 59 // other thread. | |
| 60 // This test isn't Windows-friendly yet since ASSERT_DEATH doesn't catch tests | |
| 61 // failed on DCHECK. See http://crbug.com/24885 for the details. | |
| 62 TEST(CancellationFlagTest, DISABLED_ON_WIN(SetOnDifferentThreadDeathTest)) { | |
| 63 // Checks that Set() can't be called from any other thread. | 53 // Checks that Set() can't be called from any other thread. |
| 54 // CancellationFlag should die on a DCHECK if Set() is called from |
| 55 // other thread. |
| 64 ::testing::FLAGS_gtest_death_test_style = "threadsafe"; | 56 ::testing::FLAGS_gtest_death_test_style = "threadsafe"; |
| 65 Thread t("CancellationFlagTest.SetOnDifferentThreadDeathTest"); | 57 Thread t("CancellationFlagTest.SetOnDifferentThreadDeathTest"); |
| 66 ASSERT_TRUE(t.Start()); | 58 ASSERT_TRUE(t.Start()); |
| 67 ASSERT_TRUE(t.message_loop()); | 59 ASSERT_TRUE(t.message_loop()); |
| 68 ASSERT_TRUE(t.IsRunning()); | 60 ASSERT_TRUE(t.IsRunning()); |
| 69 | 61 |
| 70 CancellationFlag flag; | 62 CancellationFlag flag; |
| 71 t.message_loop()->PostTask(FROM_HERE, new CancelTask(&flag)); | 63 t.message_loop()->PostTask(FROM_HERE, new CancelTask(&flag)); |
| 72 } | 64 } |
| 73 | 65 |
| 74 } // namespace | 66 } // namespace |
| OLD | NEW |