Index: base/process/private_working_set_snapshot_win_unittest.cc |
diff --git a/base/process/private_working_set_snapshot_win_unittest.cc b/base/process/private_working_set_snapshot_win_unittest.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..b9e3498c478c70c84800962f91e17c899bff9763 |
--- /dev/null |
+++ b/base/process/private_working_set_snapshot_win_unittest.cc |
@@ -0,0 +1,37 @@ |
+// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
ncarter (slow)
2015/06/26 21:46:16
2015, no (c)
brucedawson
2015/06/27 00:13:06
Done.
|
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "base/process/private_working_set_snapshot.h" |
+ |
+#include "base/win/windows_version.h" |
+#include "testing/gtest/include/gtest/gtest.h" |
+ |
+typedef testing::Test PrivateWorkingSetSnapshotWinTest; |
ncarter (slow)
2015/06/26 21:46:16
Apparently we're supposed to prefer C++11 aliases
brucedawson
2015/06/27 00:13:06
Done.
|
+ |
+TEST_F(PrivateWorkingSetSnapshotWinTest, FindPidSelfTest) { |
+ // The Pdh APIs are supported on Windows XP, but the "Working Set - Private" |
+ // counter that PrivateWorkingSetSnapshot depends on is not defined until |
+ // Windows Vista. Early-out to avoid test failure. |
+ if (base::win::GetVersion() < base::win::VERSION_VISTA) |
+ return; |
+ |
+ // Sample this process. |
+ base::ProcessId pid = base::GetCurrentProcId(); |
+ |
+ base::PrivateWorkingSetSnapshot private_ws_snapshot; |
+ |
+ private_ws_snapshot.AddToMonitorList("base_unittests"); |
+ private_ws_snapshot.Sample(); |
+ |
+ size_t private_ws = private_ws_snapshot.GetPrivateWorkingSet(pid); |
+ // Private working set is difficult to predict but should be at least several |
+ // MB. Initial tests show a value of ~4 MB to 25 MB depending on how many |
+ // tests and processes are used. Anomalously small or large values would |
+ // warrant investigation. |
+ EXPECT_GT(private_ws, 2000000u); |
+ // Check that the WS is less than 500 MB. This is set very high to reduce the |
+ // change that unrelated changes could ever make this fail. This mostly just |
ncarter (slow)
2015/06/26 21:46:16
change->chance
brucedawson
2015/06/27 00:13:05
Done.
|
+ // checks against some uncaught error that might return 0xFFFFFFFF. |
ncarter (slow)
2015/06/26 21:46:16
There are two things to worry about here. One is p
brucedawson
2015/06/27 00:13:06
Done.
|
+ EXPECT_LT(private_ws, 500000000u); |
ncarter (slow)
2015/06/26 21:46:16
In a test similar to this (of code that reported m
brucedawson
2015/06/27 00:13:06
Sounds good. Done.
|
+} |