OLD | NEW |
| (Empty) |
1 // Copyright 2003-2009 Google Inc. | |
2 // | |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | |
4 // you may not use this file except in compliance with the License. | |
5 // You may obtain a copy of the License at | |
6 // | |
7 // http://www.apache.org/licenses/LICENSE-2.0 | |
8 // | |
9 // Unless required by applicable law or agreed to in writing, software | |
10 // distributed under the License is distributed on an "AS IS" BASIS, | |
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
12 // See the License for the specific language governing permissions and | |
13 // limitations under the License. | |
14 // ======================================================================== | |
15 // System unittest | |
16 // | |
17 // TODO(omaha): there are some untested functions: memory stats, thread | |
18 // priorities, getdirsize (that's mine), backup/restore of registry trees.. not | |
19 // sure how high priority it is to test these things but should probably be | |
20 // added | |
21 | |
22 #include "omaha/base/system.h" | |
23 #include "omaha/testing/unit_test.h" | |
24 | |
25 namespace omaha { | |
26 | |
27 TEST(SystemTest, System) { | |
28 uint32 time_waited = 0; | |
29 ASSERT_SUCCEEDED(System::WaitForDiskActivity(10000, 25, &time_waited)); | |
30 | |
31 uint64 free_bytes_current_user = 0; | |
32 uint64 total_bytes_current_user = 0; | |
33 uint64 free_bytes_all_users = 0; | |
34 ASSERT_SUCCEEDED(System::GetDiskStatistics(_T("C:\\"), | |
35 &free_bytes_current_user, | |
36 &total_bytes_current_user, | |
37 &free_bytes_all_users)); | |
38 | |
39 ASSERT_EQ(System::GetProcessHandleCount(), | |
40 System::GetProcessHandleCountOld()); | |
41 } | |
42 | |
43 // Assume the workstations and PULSE are not running on batteries. The test | |
44 // fails on laptops running on batteries. | |
45 TEST(SystemTest, IsRunningOnBatteries) { | |
46 ASSERT_FALSE(System::IsRunningOnBatteries()); | |
47 } | |
48 | |
49 TEST(SystemTest, GetProcessMemoryStatistics) { | |
50 uint64 current_working_set(0); | |
51 uint64 peak_working_set(0); | |
52 uint64 min_working_set_size(0); | |
53 uint64 max_working_set_size(0); | |
54 ASSERT_HRESULT_SUCCEEDED( | |
55 System::GetProcessMemoryStatistics(¤t_working_set, | |
56 &peak_working_set, | |
57 &min_working_set_size, | |
58 &max_working_set_size)); | |
59 EXPECT_LT(0, current_working_set); | |
60 EXPECT_LT(0, peak_working_set); | |
61 EXPECT_LT(0, min_working_set_size); | |
62 EXPECT_LT(0, max_working_set_size); | |
63 } | |
64 | |
65 TEST(SystemTest, GetProcessHandleCount) { | |
66 DWORD handle_count(0); | |
67 ASSERT_TRUE(::GetProcessHandleCount(::GetCurrentProcess(), &handle_count)); | |
68 EXPECT_LE(0u, handle_count); | |
69 EXPECT_EQ(handle_count, System::GetProcessHandleCount()); | |
70 } | |
71 | |
72 } // namespace omaha | |
73 | |
OLD | NEW |