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

Unified Diff: mojo/public/cpp/utility/tests/thread_unittest.cc

Issue 814543006: Move //mojo/{public, edk} underneath //third_party (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/public/cpp/utility/tests/run_loop_unittest.cc ('k') | mojo/public/cpp/utility/thread.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/cpp/utility/tests/thread_unittest.cc
diff --git a/mojo/public/cpp/utility/tests/thread_unittest.cc b/mojo/public/cpp/utility/tests/thread_unittest.cc
deleted file mode 100644
index 57c4ad9b19244bd44a2c40e592b27f79b4785070..0000000000000000000000000000000000000000
--- a/mojo/public/cpp/utility/tests/thread_unittest.cc
+++ /dev/null
@@ -1,106 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "mojo/public/cpp/utility/thread.h"
-
-#include "mojo/public/cpp/system/macros.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace mojo {
-namespace {
-
-class SetIntThread : public Thread {
- public:
- SetIntThread(int* int_to_set, int value)
- : int_to_set_(int_to_set),
- value_(value) {
- }
- SetIntThread(const Options& options, int* int_to_set, int value)
- : Thread(options),
- int_to_set_(int_to_set),
- value_(value) {
- }
-
- ~SetIntThread() override {}
-
- void Run() override { *int_to_set_ = value_; }
-
- private:
- int* const int_to_set_;
- const int value_;
-
- MOJO_DISALLOW_COPY_AND_ASSIGN(SetIntThread);
-};
-
-TEST(ThreadTest, CreateAndJoin) {
- int value = 0;
-
- // Not starting the thread should result in a no-op.
- {
- SetIntThread thread(&value, 1234567);
- }
- EXPECT_EQ(0, value);
-
- // Start and join.
- {
- SetIntThread thread(&value, 12345678);
- thread.Start();
- thread.Join();
- EXPECT_EQ(12345678, value);
- }
-
- // Ditto, with non-default (but reasonable) stack size.
- {
- Thread::Options options;
- options.set_stack_size(1024 * 1024); // 1 MB.
- SetIntThread thread(options, &value, 12345678);
- thread.Start();
- thread.Join();
- EXPECT_EQ(12345678, value);
- }
-}
-
-// Tests of assertions for Debug builds.
-// Note: It's okay to create threads, despite gtest having to fork. (The threads
-// are in the child process.)
-#if !defined(NDEBUG)
-TEST(ThreadTest, DebugAssertionFailures) {
- // Can only start once.
- EXPECT_DEATH_IF_SUPPORTED({
- int value = 0;
- SetIntThread thread(&value, 1);
- thread.Start();
- thread.Start();
- }, "");
-
- // Must join (if you start).
- EXPECT_DEATH_IF_SUPPORTED({
- int value = 0;
- SetIntThread thread(&value, 2);
- thread.Start();
- }, "");
-
- // Can only join once.
- EXPECT_DEATH_IF_SUPPORTED({
- int value = 0;
- SetIntThread thread(&value, 3);
- thread.Start();
- thread.Join();
- thread.Join();
- }, "");
-
- // Stack too big (we're making certain assumptions here).
- EXPECT_DEATH_IF_SUPPORTED({
- int value = 0;
- Thread::Options options;
- options.set_stack_size(static_cast<size_t>(-1));
- SetIntThread thread(options, &value, 4);
- thread.Start();
- thread.Join();
- }, "");
-}
-#endif // !defined(NDEBUG)
-
-} // namespace
-} // namespace mojo
« no previous file with comments | « mojo/public/cpp/utility/tests/run_loop_unittest.cc ('k') | mojo/public/cpp/utility/thread.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698