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

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

Issue 217443002: Mojo: Move mojo/public/utility to mojo/public/cpp/utility. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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/utility/tests/run_loop_unittest.cc ('k') | mojo/public/utility/thread.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/utility/tests/thread_unittest.cc
diff --git a/mojo/public/utility/tests/thread_unittest.cc b/mojo/public/utility/tests/thread_unittest.cc
deleted file mode 100644
index 094b1927ccb96348f6cf37451b71ccecae48ed35..0000000000000000000000000000000000000000
--- a/mojo/public/utility/tests/thread_unittest.cc
+++ /dev/null
@@ -1,110 +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/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) {
- }
-
- virtual ~SetIntThread() {
- }
-
- virtual void Run() MOJO_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({
- int value = 0;
- SetIntThread thread(&value, 1);
- thread.Start();
- thread.Start();
- }, "");
-
- // Must join (if you start).
- EXPECT_DEATH({
- int value = 0;
- SetIntThread thread(&value, 2);
- thread.Start();
- }, "");
-
- // Can only join once.
- EXPECT_DEATH({
- int value = 0;
- SetIntThread thread(&value, 3);
- thread.Start();
- thread.Join();
- thread.Join();
- }, "");
-
- // Stack too big (we're making certain assumptions here).
- EXPECT_DEATH({
- 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/utility/tests/run_loop_unittest.cc ('k') | mojo/public/utility/thread.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698