Index: services/resource_coordinator/coordination_unit/process_coordination_unit_impl_unittest.cc |
diff --git a/services/resource_coordinator/coordination_unit/process_coordination_unit_impl_unittest.cc b/services/resource_coordinator/coordination_unit/process_coordination_unit_impl_unittest.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..a5fe04bed1663c5ab5d7a86d71008409a50ff4cf |
--- /dev/null |
+++ b/services/resource_coordinator/coordination_unit/process_coordination_unit_impl_unittest.cc |
@@ -0,0 +1,35 @@ |
+// Copyright 2017 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/process/process_handle.h" |
+#include "base/run_loop.h" |
+#include "services/resource_coordinator/coordination_unit/coordination_unit_factory.h" |
+#include "services/resource_coordinator/coordination_unit/coordination_unit_impl.h" |
+#include "services/resource_coordinator/coordination_unit/coordination_unit_impl_base_test_unittest.h" |
+#include "services/resource_coordinator/public/cpp/coordination_unit_id.h" |
+#include "services/resource_coordinator/public/cpp/coordination_unit_types.h" |
+#include "testing/gtest/include/gtest/gtest.h" |
+ |
+namespace resource_coordinator { |
+ |
+namespace { |
+ |
+class ProcessCoordinationUnitImplTest : public CoordinationUnitImplBaseTest {}; |
+ |
+} // namespace |
+ |
+TEST_F(ProcessCoordinationUnitImplTest, MeasureCPUUsage) { |
+ base::ProcessHandle current_pid = base::GetCurrentProcessHandle(); |
+ CoordinationUnitID cu_id(CoordinationUnitType::kProcess, current_pid); |
+ |
+ std::unique_ptr<CoordinationUnitImpl> coordination_unit_ = |
+ CoordinationUnitFactory::CreateCoordinationUnit( |
+ cu_id, ServiceContextRefFactory()); |
oystein (OOO til 10th of July)
2017/05/17 23:06:07
Do we know what happens to the created ServiceCont
matthalp
2017/05/18 16:13:46
Maybe I am misunderstanding, but I think this has
oystein (OOO til 10th of July)
2017/05/18 21:24:32
Yeah but it's being created from the ServiceContex
|
+ |
+ base::RunLoop().RunUntilIdle(); |
+ |
+ EXPECT_LE(0.0, coordination_unit_->GetCPUUsageForTesting()); |
oystein (OOO til 10th of July)
2017/05/17 23:06:07
Shouldn't this be EXPECT_GE?
matthalp
2017/05/18 16:13:46
EXPECT_LE(val1, val2) verifies val1 <= val2 [1] an
oystein (OOO til 10th of July)
2017/05/18 21:24:32
Makes sense!
|
+} |
+ |
+} // namespace resource_coordinator |