| OLD | NEW |
| (Empty) |
| 1 // Copyright 2004-2010 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 | |
| 16 #include <shlobj.h> | |
| 17 #include <psapi.h> | |
| 18 | |
| 19 #include "omaha/base/app_util.h" | |
| 20 #include "omaha/base/const_utils.h" | |
| 21 #include "omaha/base/disk.h" | |
| 22 #include "omaha/base/file.h" | |
| 23 #include "omaha/base/vistautil.h" | |
| 24 #include "omaha/testing/unit_test.h" | |
| 25 | |
| 26 namespace omaha { | |
| 27 | |
| 28 TEST(DiskTest, GetFreeDiskSpace) { | |
| 29 uint64 bytes_available = 0; | |
| 30 EXPECT_SUCCEEDED(GetFreeDiskSpace(_T("C:\\"), &bytes_available)); | |
| 31 | |
| 32 bytes_available = 0; | |
| 33 EXPECT_SUCCEEDED(GetFreeDiskSpace(CSIDL_PROGRAM_FILES, &bytes_available)); | |
| 34 } | |
| 35 | |
| 36 TEST(DiskTest, Disk_SystemDrive) { | |
| 37 TCHAR system_drive[MAX_PATH] = _T("%SystemDrive%"); | |
| 38 EXPECT_TRUE(::ExpandEnvironmentStrings(system_drive, system_drive, MAX_PATH)); | |
| 39 EXPECT_TRUE(::PathAddBackslash(system_drive)); | |
| 40 | |
| 41 if (vista_util::IsUserAdmin()) { | |
| 42 // System drive should not be hot-pluggable | |
| 43 EXPECT_FALSE(IsHotPluggable(system_drive)); | |
| 44 } | |
| 45 | |
| 46 // System drive is expected to be > 4GB. | |
| 47 EXPECT_TRUE(IsLargeDrive(system_drive)); | |
| 48 } | |
| 49 | |
| 50 TEST(DiskTest, Disk_FirstLargeLocalDrive) { | |
| 51 // Preferred amount of disk space for data (choose first location if found). | |
| 52 // Ideally this would be 1 GB, but some test VMs have little free space. | |
| 53 const int kDesiredSpace = 100 * 1000 * 1000; // 100 MB | |
| 54 | |
| 55 CString drive; | |
| 56 EXPECT_SUCCEEDED(FindFirstLocalDriveWithEnoughSpace(kDesiredSpace, &drive)); | |
| 57 EXPECT_TRUE(IsLargeDrive(drive)); | |
| 58 } | |
| 59 | |
| 60 // TODO(omaha): Make this work on mapped drives. See http://b/1076675. | |
| 61 TEST(DiskTest, DISABLED_DevicePathToDosPath) { | |
| 62 TCHAR image_name[MAX_PATH] = _T(""); | |
| 63 EXPECT_TRUE(::GetProcessImageFileName(::GetCurrentProcess(), | |
| 64 image_name, | |
| 65 arraysize(image_name)) != 0); | |
| 66 | |
| 67 CString dos_name; | |
| 68 EXPECT_SUCCEEDED(DevicePathToDosPath(image_name, &dos_name)); | |
| 69 EXPECT_TRUE(File::Exists(dos_name)); | |
| 70 | |
| 71 EXPECT_EQ(dos_name.CompareNoCase(app_util::GetCurrentModulePath()), 0); | |
| 72 } | |
| 73 | |
| 74 } // namespace omaha | |
| OLD | NEW |