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

Unified Diff: mojo/public/tests/test_utils.cc

Issue 218833003: Mojo: Move public/tests/test_{support,utils}.* to public/{c,cpp}/test_support. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix gyp 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/tests/test_utils.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/tests/test_utils.cc
diff --git a/mojo/public/tests/test_utils.cc b/mojo/public/tests/test_utils.cc
deleted file mode 100644
index 2e9bc3896f66b95bce35a8ca76b51dc06a778acf..0000000000000000000000000000000000000000
--- a/mojo/public/tests/test_utils.cc
+++ /dev/null
@@ -1,91 +0,0 @@
-// Copyright 2013 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/tests/test_utils.h"
-
-#include "mojo/public/cpp/system/core.h"
-#include "mojo/public/tests/test_support.h"
-
-namespace mojo {
-namespace test {
-
-bool WriteTextMessage(const MessagePipeHandle& handle,
- const std::string& text) {
- MojoResult rv = WriteMessageRaw(handle,
- text.data(),
- static_cast<uint32_t>(text.size()),
- NULL,
- 0,
- MOJO_WRITE_MESSAGE_FLAG_NONE);
- return rv == MOJO_RESULT_OK;
-}
-
-bool ReadTextMessage(const MessagePipeHandle& handle, std::string* text) {
- MojoResult rv;
- bool did_wait = false;
-
- uint32_t num_bytes = 0, num_handles = 0;
- for (;;) {
- rv = ReadMessageRaw(handle,
- NULL,
- &num_bytes,
- NULL,
- &num_handles,
- MOJO_READ_MESSAGE_FLAG_NONE);
- if (rv == MOJO_RESULT_SHOULD_WAIT) {
- if (did_wait) {
- assert(false); // Looping endlessly!?
- return false;
- }
- rv = Wait(handle, MOJO_WAIT_FLAG_READABLE, MOJO_DEADLINE_INDEFINITE);
- if (rv != MOJO_RESULT_OK)
- return false;
- did_wait = true;
- } else {
- assert(!num_handles);
- break;
- }
- }
-
- text->resize(num_bytes);
- rv = ReadMessageRaw(handle,
- &text->at(0),
- &num_bytes,
- NULL,
- &num_handles,
- MOJO_READ_MESSAGE_FLAG_NONE);
- return rv == MOJO_RESULT_OK;
-}
-
-bool DiscardMessage(const MessagePipeHandle& handle) {
- MojoResult rv = ReadMessageRaw(handle, NULL, NULL, NULL, NULL,
- MOJO_READ_MESSAGE_FLAG_MAY_DISCARD);
- return rv == MOJO_RESULT_OK;
-}
-
-void IterateAndReportPerf(const char* test_name,
- PerfTestSingleIteration single_iteration,
- void* closure) {
- // TODO(vtl): These should be specifiable using command-line flags.
- static const size_t kGranularity = 100;
- static const MojoTimeTicks kPerftestTimeMicroseconds = 3 * 1000000;
-
- const MojoTimeTicks start_time = GetTimeTicksNow();
- MojoTimeTicks end_time;
- size_t iterations = 0;
- do {
- for (size_t i = 0; i < kGranularity; i++)
- (*single_iteration)(closure);
- iterations += kGranularity;
-
- end_time = GetTimeTicksNow();
- } while (end_time - start_time < kPerftestTimeMicroseconds);
-
- MojoTestSupportLogPerfResult(test_name,
- 1000000.0 * iterations / (end_time - start_time),
- "iterations/second");
-}
-
-} // namespace test
-} // namespace mojo
« no previous file with comments | « mojo/public/tests/test_utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698