-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Found and fixed duplicate method definitions for the same API
- Loading branch information
Lyor Goldstein
committed
Aug 6, 2015
1 parent
ab7eea6
commit 00e6184
Showing
8 changed files
with
995 additions
and
982 deletions.
There are no files selected for viewing
584 changes: 235 additions & 349 deletions
584
contrib/platform/src/com/sun/jna/platform/win32/Kernel32.java
Large diffs are not rendered by default.
Oops, something went wrong.
607 changes: 270 additions & 337 deletions
607
contrib/platform/src/com/sun/jna/platform/win32/User32.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
370 changes: 194 additions & 176 deletions
370
contrib/platform/test/com/sun/jna/platform/win32/Advapi32Test.java
Large diffs are not rendered by default.
Oops, something went wrong.
120 changes: 120 additions & 0 deletions
120
contrib/platform/test/com/sun/jna/platform/win32/Kernel32DiskManagementFunctionsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 2.1 of the License, or (at your option) any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
*/ | ||
package com.sun.jna.platform.win32; | ||
|
||
import java.io.File; | ||
import java.util.List; | ||
|
||
import org.junit.Test; | ||
|
||
import com.sun.jna.platform.win32.WinDef.DWORD; | ||
import com.sun.jna.platform.win32.WinDef.DWORDByReference; | ||
import com.sun.jna.platform.win32.WinNT.LARGE_INTEGER; | ||
|
||
public class Kernel32DiskManagementFunctionsTest extends AbstractWin32TestSupport { | ||
public Kernel32DiskManagementFunctionsTest() { | ||
super(); | ||
} | ||
|
||
@Test | ||
public void testGetDiskFreeSpaceEx() { | ||
List<String> driveList = Kernel32Util.getLogicalDriveStrings(); | ||
for (int index = (-1); index < driveList.size(); index++) { | ||
String driveName = (index < 0) ? null : driveList.get(index); | ||
if (driveName != null) { | ||
// according to the documentation must end with a backslash | ||
if (driveName.charAt(driveName.length() - 1) != File.separatorChar) { | ||
driveName += File.separator; | ||
} | ||
|
||
int driveType = Kernel32.INSTANCE.GetDriveType(driveName); | ||
/* | ||
* Don't try DVD or network drives since they may yield errors | ||
* for the test - e.g., DEVICE_NOT_READY | ||
*/ | ||
if (driveType != WinNT.DRIVE_FIXED) { | ||
continue; | ||
} | ||
} | ||
|
||
testGetDiskFreeSpaceEx(driveName); | ||
} | ||
} | ||
|
||
private void testGetDiskFreeSpaceEx(String lpDirectoryName) { | ||
LARGE_INTEGER.ByReference lpFreeBytesAvailable = new LARGE_INTEGER.ByReference(); | ||
LARGE_INTEGER.ByReference lpTotalNumberOfBytes = new LARGE_INTEGER.ByReference(); | ||
LARGE_INTEGER.ByReference lpTotalNumberOfFreeBytes = new LARGE_INTEGER.ByReference(); | ||
assertCallSucceeded("GetDiskFreeSpaceEx(" + lpDirectoryName + ")", | ||
Kernel32.INSTANCE.GetDiskFreeSpaceEx(lpDirectoryName, | ||
lpFreeBytesAvailable, lpTotalNumberOfBytes, lpTotalNumberOfFreeBytes)); | ||
|
||
// System.out.append(getCurrentTestName()).append('[').append(lpDirectoryName).println(']'); | ||
// System.out.append('\t').append("FreeBytesAvailable: ").println(lpFreeBytesAvailable); | ||
// System.out.append('\t').append("TotalNumberOfBytes: ").println(lpTotalNumberOfBytes); | ||
// System.out.append('\t').append("TotalNumberOfFreeBytes: ").println(lpTotalNumberOfFreeBytes); | ||
|
||
assertTrue("No free size for " + lpDirectoryName, lpTotalNumberOfFreeBytes.getValue() > 0L); | ||
assertTrue("Free size (" + lpTotalNumberOfFreeBytes + ")" | ||
+ " not below total size (" + lpTotalNumberOfBytes + ")" | ||
+ " for " + lpDirectoryName, | ||
lpTotalNumberOfFreeBytes.getValue() < lpTotalNumberOfBytes.getValue()); | ||
} | ||
|
||
@Test | ||
public void testGetDiskFreeSpace() { | ||
List<String> driveList = Kernel32Util.getLogicalDriveStrings(); | ||
for (int index = (-1); index < driveList.size(); index++) { | ||
String driveName = (index < 0) ? null : driveList.get(index); | ||
if (driveName != null) { | ||
// according to the documentation must end with a backslash | ||
if (driveName.charAt(driveName.length() - 1) != File.separatorChar) { | ||
driveName += File.separator; | ||
} | ||
|
||
int driveType = Kernel32.INSTANCE.GetDriveType(driveName); | ||
/* | ||
* Don't try DVD or network drives since they may yield errors | ||
* for the test - e.g., DEVICE_NOT_READY | ||
*/ | ||
if (driveType != WinNT.DRIVE_FIXED) { | ||
continue; | ||
} | ||
} | ||
|
||
testGetDiskFreeSpace(driveName); | ||
} | ||
} | ||
|
||
private void testGetDiskFreeSpace(String lpRootPathName) { | ||
DWORDByReference lpSectorsPerCluster = new DWORDByReference(); | ||
DWORDByReference lpBytesPerSector = new DWORDByReference(); | ||
DWORDByReference lpNumberOfFreeClusters = new DWORDByReference(); | ||
DWORDByReference lpTotalNumberOfClusters = new DWORDByReference(); | ||
assertCallSucceeded("GetDiskFreeSpace(" + lpRootPathName + ")", | ||
Kernel32.INSTANCE.GetDiskFreeSpace(lpRootPathName, | ||
lpSectorsPerCluster, lpBytesPerSector, lpNumberOfFreeClusters, lpTotalNumberOfClusters)); | ||
|
||
// System.out.append(getCurrentTestName()).append('[').append(lpRootPathName).println(']'); | ||
// System.out.append('\t').append("SectorsPerCluster: ").println(lpSectorsPerCluster.getValue()); | ||
// System.out.append('\t').append("BytesPerSector: ").println(lpBytesPerSector.getValue()); | ||
// System.out.append('\t').append("NumberOfFreeClusters: ").println(lpNumberOfFreeClusters.getValue()); | ||
// System.out.append('\t').append("TotalNumberOfClusters: ").println(lpTotalNumberOfClusters.getValue()); | ||
|
||
DWORD freeSize = lpNumberOfFreeClusters.getValue(); | ||
assertTrue("No free clusters for " + lpRootPathName, freeSize.longValue() > 0L); | ||
|
||
DWORD totalSize = lpTotalNumberOfClusters.getValue(); | ||
assertTrue("Free clusters (" + freeSize + ") not below total (" + totalSize + ") for " + lpRootPathName, freeSize.longValue() < totalSize.longValue()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.