| 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 <fstream> | 5 #include <fstream> |
| 6 | 6 |
| 7 #include "base/base_paths.h" | 7 #include "base/base_paths.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/files/file.h" | 9 #include "base/files/file.h" |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 base::FilePath home_path() { return fake_home_dir_.path(); } | 116 base::FilePath home_path() { return fake_home_dir_.path(); } |
| 117 | 117 |
| 118 private: | 118 private: |
| 119 base::ScopedTempDir fake_home_dir_; | 119 base::ScopedTempDir fake_home_dir_; |
| 120 ScopedTempFile minidump_; | 120 ScopedTempFile minidump_; |
| 121 std::unique_ptr<base::ScopedPathOverride> home_override_; | 121 std::unique_ptr<base::ScopedPathOverride> home_override_; |
| 122 | 122 |
| 123 DISALLOW_COPY_AND_ASSIGN(CastCrashReporterClientTest); | 123 DISALLOW_COPY_AND_ASSIGN(CastCrashReporterClientTest); |
| 124 }; | 124 }; |
| 125 | 125 |
| 126 #if ENABLE_THREAD_RESTRICTIONS | 126 #if DCHECK_IS_ON() |
| 127 // This test shall only be run when thread restricitons are enabled. Otherwise, | 127 // This test shall only be run when thread restricitons are enabled. Otherwise, |
| 128 // the thread will not actually be IO-restricted, and the final ASSERT will | 128 // the thread will not actually be IO-restricted, and the final ASSERT will |
| 129 // fail. | 129 // fail. |
| 130 TEST_F(CastCrashReporterClientTest, EndToEndTestOnIORestrictedThread) { | 130 TEST_F(CastCrashReporterClientTest, EndToEndTestOnIORestrictedThread) { |
| 131 // Handle a "crash" on an IO restricted thread. | 131 // Handle a "crash" on an IO restricted thread. |
| 132 base::ThreadRestrictions::SetIOAllowed(false); | 132 base::ThreadRestrictions::SetIOAllowed(false); |
| 133 CastCrashReporterClient client; | 133 CastCrashReporterClient client; |
| 134 ASSERT_TRUE(client.HandleCrashDump(minidump_path().value().c_str())); | 134 ASSERT_TRUE(client.HandleCrashDump(minidump_path().value().c_str())); |
| 135 | 135 |
| 136 // Assert that the thread is IO restricted when the function exits. | 136 // Assert that the thread is IO restricted when the function exits. |
| 137 // Note that SetIOAllowed returns the previous value. | 137 // Note that SetIOAllowed returns the previous value. |
| 138 ASSERT_FALSE(base::ThreadRestrictions::SetIOAllowed(true)); | 138 ASSERT_FALSE(base::ThreadRestrictions::SetIOAllowed(true)); |
| 139 } | 139 } |
| 140 #endif // ENABLE_THREAD_RESTRICTIONS | 140 #endif // DCHECK_IS_ON() |
| 141 | 141 |
| 142 TEST_F(CastCrashReporterClientTest, EndToEndTestOnNonIORestrictedThread) { | 142 TEST_F(CastCrashReporterClientTest, EndToEndTestOnNonIORestrictedThread) { |
| 143 // Handle a crash on a non-IO restricted thread. | 143 // Handle a crash on a non-IO restricted thread. |
| 144 base::ThreadRestrictions::SetIOAllowed(true); | 144 base::ThreadRestrictions::SetIOAllowed(true); |
| 145 CastCrashReporterClient client; | 145 CastCrashReporterClient client; |
| 146 ASSERT_TRUE(client.HandleCrashDump(minidump_path().value().c_str())); | 146 ASSERT_TRUE(client.HandleCrashDump(minidump_path().value().c_str())); |
| 147 | 147 |
| 148 // Assert that the thread is not IO restricted when the function exits. | 148 // Assert that the thread is not IO restricted when the function exits. |
| 149 // Note that SetIOAllowed returns the previous value. | 149 // Note that SetIOAllowed returns the previous value. |
| 150 ASSERT_TRUE(base::ThreadRestrictions::SetIOAllowed(true)); | 150 ASSERT_TRUE(base::ThreadRestrictions::SetIOAllowed(true)); |
| 151 } | 151 } |
| 152 | 152 |
| 153 } // namespace chromecast | 153 } // namespace chromecast |
| OLD | NEW |