EDK: Remove (direct) dependencies of //mojo/edk/system on //base/test.

We still use //base/test for the moment, but only via things in
//mojo/edk/system/test.

R=vardhan@google.com

Review URL: https://codereview.chromium.org/1430593005 .
diff --git a/mojo/edk/system/BUILD.gn b/mojo/edk/system/BUILD.gn
index 8d7e0b6..f7227f3 100644
--- a/mojo/edk/system/BUILD.gn
+++ b/mojo/edk/system/BUILD.gn
@@ -180,7 +180,6 @@
     "ref_counted_unittest.cc",
     "remote_data_pipe_impl_unittest.cc",
     "remote_message_pipe_unittest.cc",
-    "run_all_unittests.cc",
     "shared_buffer_dispatcher_unittest.cc",
     "simple_dispatcher_unittest.cc",
     "test_channel_endpoint_client.cc",
@@ -198,13 +197,11 @@
     "../test:test_support",
     "../util",
     "test",
+    "test:run_all_unittests",
     "test:unittests",
     "//base",
-    "//base/test:test_support",
     "//testing/gtest",
   ]
-
-  allow_circular_includes_from = [ "../embedder:embedder_unittests" ]
 }
 
 test("mojo_system_perftests") {
@@ -219,9 +216,9 @@
     ":system",
     "../test:test_support",
     "test",
+    "test:perf",
+    "test:run_all_perftests",
     "//base",
-    "//base/test:test_support",
-    "//base/test:test_support_perf",
     "//testing/gtest",
   ]
 }
diff --git a/mojo/edk/system/channel_endpoint_unittest.cc b/mojo/edk/system/channel_endpoint_unittest.cc
index 19cc237..b83afc4 100644
--- a/mojo/edk/system/channel_endpoint_unittest.cc
+++ b/mojo/edk/system/channel_endpoint_unittest.cc
@@ -8,11 +8,12 @@
 #include <utility>
 
 #include "base/synchronization/waitable_event.h"
-#include "base/test/test_timeouts.h"
+#include "base/time/time.h"
 #include "mojo/edk/system/channel_test_base.h"
 #include "mojo/edk/system/message_in_transit_queue.h"
 #include "mojo/edk/system/message_in_transit_test_utils.h"
 #include "mojo/edk/system/ref_ptr.h"
+#include "mojo/edk/system/test/timeouts.h"
 #include "mojo/edk/system/test_channel_endpoint_client.h"
 #include "mojo/public/cpp/system/macros.h"
 
@@ -76,7 +77,8 @@
   EXPECT_TRUE(endpoint1->EnqueueMessage(std::move(send_message)));
 
   // Wait to receive it.
-  EXPECT_TRUE(read_event.TimedWait(TestTimeouts::tiny_timeout()));
+  EXPECT_TRUE(read_event.TimedWait(base::TimeDelta::FromMicroseconds(
+      static_cast<int64_t>(test::TinyTimeout()))));
   client0->SetReadEvent(nullptr);
 
   // Check the received message.
@@ -116,7 +118,8 @@
   base::WaitableEvent read_event(true, false);
   client0->SetReadEvent(&read_event);
   for (size_t i = 0; client0->NumMessages() < 6 && i < 6; i++) {
-    EXPECT_TRUE(read_event.TimedWait(TestTimeouts::tiny_timeout()));
+    EXPECT_TRUE(read_event.TimedWait(base::TimeDelta::FromMicroseconds(
+        static_cast<int64_t>(test::TinyTimeout()))));
     read_event.Reset();
   }
   client0->SetReadEvent(nullptr);
diff --git a/mojo/edk/system/endpoint_relayer_unittest.cc b/mojo/edk/system/endpoint_relayer_unittest.cc
index 1b8b440..ca35d7d 100644
--- a/mojo/edk/system/endpoint_relayer_unittest.cc
+++ b/mojo/edk/system/endpoint_relayer_unittest.cc
@@ -6,12 +6,13 @@
 
 #include "base/logging.h"
 #include "base/synchronization/waitable_event.h"
-#include "base/test/test_timeouts.h"
+#include "base/time/time.h"
 #include "mojo/edk/system/channel_endpoint_id.h"
 #include "mojo/edk/system/channel_test_base.h"
 #include "mojo/edk/system/message_in_transit_queue.h"
 #include "mojo/edk/system/message_in_transit_test_utils.h"
 #include "mojo/edk/system/ref_ptr.h"
+#include "mojo/edk/system/test/timeouts.h"
 #include "mojo/edk/system/test_channel_endpoint_client.h"
 #include "mojo/edk/util/make_unique.h"
 #include "mojo/public/cpp/system/macros.h"
@@ -96,7 +97,8 @@
 
   EXPECT_TRUE(endpoint1a()->EnqueueMessage(test::MakeTestMessage(12345)));
 
-  EXPECT_TRUE(read_event.TimedWait(TestTimeouts::tiny_timeout()));
+  EXPECT_TRUE(read_event.TimedWait(base::TimeDelta::FromMicroseconds(
+      static_cast<int64_t>(test::TinyTimeout()))));
   client1b()->SetReadEvent(nullptr);
 
   ASSERT_EQ(1u, client1b()->NumMessages());
@@ -111,7 +113,8 @@
 
   EXPECT_TRUE(endpoint1b()->EnqueueMessage(test::MakeTestMessage(67890)));
 
-  EXPECT_TRUE(read_event.TimedWait(TestTimeouts::tiny_timeout()));
+  EXPECT_TRUE(read_event.TimedWait(base::TimeDelta::FromMicroseconds(
+      static_cast<int64_t>(test::TinyTimeout()))));
   client1a()->SetReadEvent(nullptr);
 
   ASSERT_EQ(1u, client1a()->NumMessages());
@@ -130,7 +133,8 @@
   base::WaitableEvent read_event(true, false);
   client1b()->SetReadEvent(&read_event);
   for (size_t i = 0; client1b()->NumMessages() < 5 && i < 5; i++) {
-    EXPECT_TRUE(read_event.TimedWait(TestTimeouts::tiny_timeout()));
+    EXPECT_TRUE(read_event.TimedWait(base::TimeDelta::FromMicroseconds(
+        static_cast<int64_t>(test::TinyTimeout()))));
     read_event.Reset();
   }
   client1b()->SetReadEvent(nullptr);
@@ -201,7 +205,8 @@
   base::WaitableEvent read_event(true, false);
   client1b()->SetReadEvent(&read_event);
   for (size_t i = 0; client1b()->NumMessages() < 5 && i < 5; i++) {
-    EXPECT_TRUE(read_event.TimedWait(TestTimeouts::tiny_timeout()));
+    EXPECT_TRUE(read_event.TimedWait(base::TimeDelta::FromMicroseconds(
+        static_cast<int64_t>(test::TinyTimeout()))));
     read_event.Reset();
   }
   client1b()->SetReadEvent(nullptr);
diff --git a/mojo/edk/system/ipc_support_unittest.cc b/mojo/edk/system/ipc_support_unittest.cc
index 2ca97a6..9ced02e 100644
--- a/mojo/edk/system/ipc_support_unittest.cc
+++ b/mojo/edk/system/ipc_support_unittest.cc
@@ -12,7 +12,7 @@
 #include "base/command_line.h"
 #include "base/logging.h"
 #include "base/synchronization/waitable_event.h"
-#include "base/test/test_timeouts.h"
+#include "base/time/time.h"
 #include "mojo/edk/embedder/master_process_delegate.h"
 #include "mojo/edk/embedder/platform_channel_pair.h"
 #include "mojo/edk/embedder/simple_platform_support.h"
@@ -125,7 +125,9 @@
   // Warning: There's only one slave disconnect event (which resets
   // automatically).
   bool TryWaitForOnSlaveDisconnect() {
-    return on_slave_disconnect_event_.TimedWait(TestTimeouts::action_timeout());
+    return on_slave_disconnect_event_.TimedWait(
+        base::TimeDelta::FromMicroseconds(
+            static_cast<int64_t>(test::ActionTimeout())));
   }
 
  private:
@@ -184,7 +186,8 @@
   }
 
   void WaitForChannelToSlave() {
-    EXPECT_TRUE(event_.TimedWait(TestTimeouts::action_timeout()));
+    EXPECT_TRUE(event_.TimedWait(base::TimeDelta::FromMicroseconds(
+        static_cast<int64_t>(test::ActionTimeout()))));
   }
 
   void ShutdownChannelToSlave() {
@@ -249,7 +252,8 @@
   }
 
   void WaitForChannelToMaster() {
-    EXPECT_TRUE(event_.TimedWait(TestTimeouts::action_timeout()));
+    EXPECT_TRUE(event_.TimedWait(base::TimeDelta::FromMicroseconds(
+        static_cast<int64_t>(test::ActionTimeout()))));
   }
 
   void ShutdownChannelToMaster() {
diff --git a/mojo/edk/system/message_pipe_perftest.cc b/mojo/edk/system/message_pipe_perftest.cc
index ffa7981..ad892dd 100644
--- a/mojo/edk/system/message_pipe_perftest.cc
+++ b/mojo/edk/system/message_pipe_perftest.cc
@@ -10,13 +10,14 @@
 #include "base/bind.h"
 #include "base/logging.h"
 #include "base/strings/stringprintf.h"
-#include "base/test/perf_time_logger.h"
 #include "mojo/edk/embedder/scoped_platform_handle.h"
 #include "mojo/edk/system/local_message_pipe_endpoint.h"
 #include "mojo/edk/system/message_pipe.h"
 #include "mojo/edk/system/message_pipe_test_utils.h"
 #include "mojo/edk/system/proxy_message_pipe_endpoint.h"
 #include "mojo/edk/system/ref_ptr.h"
+#include "mojo/edk/system/test/perf_log.h"
+#include "mojo/edk/system/test/stopwatch.h"
 #include "mojo/edk/test/test_utils.h"
 #include "mojo/public/cpp/system/macros.h"
 #include "testing/gtest/include/gtest/gtest.h"
@@ -67,12 +68,12 @@
     std::string test_name =
         base::StringPrintf("IPC_Perf_%dx_%u", message_count_,
                            static_cast<unsigned>(message_size_));
-    base::PerfTimeLogger logger(test_name.c_str());
+    test::Stopwatch stopwatch;
 
+    stopwatch.Start();
     for (int i = 0; i < message_count_; ++i)
       WriteWaitThenRead(mp);
-
-    logger.Done();
+    test::LogPerfResult(test_name.c_str(), stopwatch.Elapsed() / 1000.0, "ms");
   }
 
  private:
diff --git a/mojo/edk/system/ref_counted_perftest.cc b/mojo/edk/system/ref_counted_perftest.cc
index b88e5cd..c7100fe 100644
--- a/mojo/edk/system/ref_counted_perftest.cc
+++ b/mojo/edk/system/ref_counted_perftest.cc
@@ -4,8 +4,8 @@
 
 #include <stdint.h>
 
-#include "base/test/perf_log.h"
 #include "mojo/edk/system/ref_counted.h"
+#include "mojo/edk/system/test/perf_log.h"
 #include "mojo/edk/system/test/stopwatch.h"
 #include "mojo/edk/system/test/timeouts.h"
 #include "testing/gtest/include/gtest/gtest.h"
@@ -40,7 +40,7 @@
   } while (stopwatch.Elapsed() < test::DeadlineFromMilliseconds(1000));
   double elapsed = stopwatch.Elapsed() / 1000000.0;
 
-  base::LogPerfResult("OneThreadCreateAdoptDestroy", iterations / elapsed,
+  test::LogPerfResult("OneThreadCreateAdoptDestroy", iterations / elapsed,
                       "iterations/s");
 }
 
@@ -57,7 +57,7 @@
   } while (stopwatch.Elapsed() < test::DeadlineFromMilliseconds(1000));
   double elapsed = stopwatch.Elapsed() / 1000000.0;
 
-  base::LogPerfResult("OneThreadAssignRefPtr", iterations / elapsed,
+  test::LogPerfResult("OneThreadAssignRefPtr", iterations / elapsed,
                       "iterations/s");
 }
 
diff --git a/mojo/edk/system/test/BUILD.gn b/mojo/edk/system/test/BUILD.gn
index e91db65..d1d5f1a 100644
--- a/mojo/edk/system/test/BUILD.gn
+++ b/mojo/edk/system/test/BUILD.gn
@@ -4,8 +4,10 @@
 
 import("../../mojo_edk.gni")
 
+# Utilties for use by EDK internal (unit and perf) tests.
 mojo_edk_source_set("test") {
   testonly = true
+  mojo_edk_visibility = [ "mojo/edk/*" ]
 
   sources = [
     "random.cc",
@@ -32,6 +34,7 @@
   deps = [
     "//base",
     "//base/test:test_support",
+    "//testing/gtest",
   ]
 
   mojo_edk_deps = [
@@ -40,6 +43,50 @@
   ]
 }
 
+# Utilities for use by EDK internal perf tests (for use with
+# :run_all_perftests).
+mojo_edk_source_set("perf") {
+  testonly = true
+  mojo_edk_visibility = [ "mojo/edk/*" ]
+
+  sources = [
+    "perf_log.cc",
+    "perf_log.h",
+  ]
+
+  deps = [
+    "//base/test:test_support",
+  ]
+}
+
+mojo_edk_source_set("run_all_unittests") {
+  testonly = true
+  mojo_edk_visibility = [ "mojo/edk/*" ]
+
+  sources = [
+    "run_all_unittests.cc",
+  ]
+
+  deps = [
+    "//base",
+    "//base/test:test_support",
+    "//testing/gtest",
+  ]
+}
+
+mojo_edk_source_set("run_all_perftests") {
+  testonly = true
+  mojo_edk_visibility = [ "mojo/edk/*" ]
+
+  sources = [
+    "run_all_perftests.cc",
+  ]
+
+  deps = [
+    "//base/test:test_support",
+  ]
+}
+
 mojo_edk_source_set("unittests") {
   testonly = true
   mojo_edk_visibility = [ "mojo/edk/system:mojo_system_unittests" ]
diff --git a/mojo/edk/system/test/perf_log.cc b/mojo/edk/system/test/perf_log.cc
new file mode 100644
index 0000000..5b9d738
--- /dev/null
+++ b/mojo/edk/system/test/perf_log.cc
@@ -0,0 +1,19 @@
+// Copyright 2015 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/edk/system/test/perf_log.h"
+
+#include "base/test/perf_log.h"
+
+namespace mojo {
+namespace system {
+namespace test {
+
+void LogPerfResult(const char* test_name, double value, const char* units) {
+  base::LogPerfResult(test_name, value, units);
+}
+
+}  // namespace test
+}  // namespace system
+}  // namespace mojo
diff --git a/mojo/edk/system/test/perf_log.h b/mojo/edk/system/test/perf_log.h
new file mode 100644
index 0000000..93affff
--- /dev/null
+++ b/mojo/edk/system/test/perf_log.h
@@ -0,0 +1,29 @@
+// Copyright 2015 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.
+
+// Functions for logging perf test results.
+
+#ifndef MOJO_EDK_SYSTEM_TEST_PERF_LOG_H_
+#define MOJO_EDK_SYSTEM_TEST_PERF_LOG_H_
+
+//#include "mojo/public/c/system/types.h"
+//#include "mojo/public/cpp/system/macros.h"
+
+namespace mojo {
+namespace system {
+namespace test {
+
+// TODO(vtl): Possibly should have our own "InitPerfLog()" and
+// "FinalizePerfLog()" functions, but we can't do that until we stop using
+// |base::PerfTestSuite()|. Currently,
+
+// Logs the result of a perf test. You may only call this while running inside a
+// perf test suite (using the :run_all_perftests from this directory).
+void LogPerfResult(const char* test_name, double value, const char* units);
+
+}  // namespace test
+}  // namespace system
+}  // namespace mojo
+
+#endif  // MOJO_EDK_SYSTEM_TEST_PERF_LOG_H_
diff --git a/mojo/edk/system/test/run_all_perftests.cc b/mojo/edk/system/test/run_all_perftests.cc
new file mode 100644
index 0000000..6e38109
--- /dev/null
+++ b/mojo/edk/system/test/run_all_perftests.cc
@@ -0,0 +1,9 @@
+// Copyright (c) 2012 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 "base/test/perf_test_suite.h"
+
+int main(int argc, char** argv) {
+  return base::PerfTestSuite(argc, argv).Run();
+}
diff --git a/mojo/edk/system/run_all_unittests.cc b/mojo/edk/system/test/run_all_unittests.cc
similarity index 91%
rename from mojo/edk/system/run_all_unittests.cc
rename to mojo/edk/system/test/run_all_unittests.cc
index cd61337..8dbf13d 100644
--- a/mojo/edk/system/run_all_unittests.cc
+++ b/mojo/edk/system/test/run_all_unittests.cc
@@ -2,6 +2,8 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
+// This defines the main() for EDK internal implementation unit test binaries.
+
 #include "base/bind.h"
 #include "base/test/launcher/unit_test_launcher.h"
 #include "base/test/test_suite.h"