Skip to content

Commit

Permalink
Use JUnit4 and skip DXVA tests without a physical monitor.
Browse files Browse the repository at this point in the history
  • Loading branch information
dblock committed Jun 27, 2014
1 parent ea2ccff commit 1c7e616
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
4 changes: 3 additions & 1 deletion contrib/platform/nbproject/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ dist.jar=${dist.dir}/jna-platform.jar
dist.javadoc.dir=${dist.dir}/javadoc
file.reference.jna.jar=../../build/jna.jar
file.reference.jna-test.jar=../../build/jna-test.jar
libs.junit.classpath=../../lib/junit.jar
libs.junit.classpath=\
../../lib/junit.jar:\
../../lib/hamcrest-core-1.3.jar
jar.compress=false
javac.classpath=\
${file.reference.jna.jar}:\
Expand Down
26 changes: 20 additions & 6 deletions contrib/platform/test/com/sun/jna/platform/win32/Dxva2Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@

package com.sun.jna.platform.win32;

import junit.framework.TestCase;
import org.junit.*;
import static org.junit.Assert.*;
import static org.junit.Assume.*;

import com.sun.jna.Memory;
import com.sun.jna.platform.win32.Dxva2;
Expand All @@ -41,12 +43,12 @@
/**
* @author Martin Steiger
*/
public class Dxva2Test extends TestCase {
public class Dxva2Test {

private int monitorCount;
private PHYSICAL_MONITOR[] physMons;

@Override
@Before
public void setUp()
{
HMONITOR hMonitor = User32.INSTANCE.MonitorFromPoint(new POINT(0, 0), WinUser.MONITOR_DEFAULTTOPRIMARY);
Expand All @@ -56,15 +58,17 @@ public void setUp()

monitorCount = pdwNumberOfPhysicalMonitors.getValue().intValue();
physMons = new PHYSICAL_MONITOR[monitorCount];
assertTrue(Dxva2.INSTANCE.GetPhysicalMonitorsFromHMONITOR(hMonitor, monitorCount, physMons).booleanValue());

assumeTrue(Dxva2.INSTANCE.GetPhysicalMonitorsFromHMONITOR(hMonitor, monitorCount, physMons).booleanValue());

This comment has been minimized.

Copy link
@msteiger

msteiger Jun 29, 2014

Contributor

An alternative way (independent of any native method calls) to check if a display device is present is
java.awt.GraphicsEnvironment.isHeadless(). I'm not sure if this is identical to having a physical monitor attached though (what about "Remote Desktop" environments). So, I'd just leave it as-is.

This comment has been minimized.

Copy link
@twall

twall via email Jul 3, 2014

Contributor
}

@Override
@After
public void tearDown()
{
assertTrue(Dxva2.INSTANCE.DestroyPhysicalMonitors(monitorCount, physMons).booleanValue());
Dxva2.INSTANCE.DestroyPhysicalMonitors(monitorCount, physMons);
}

@Test
public void testGetMonitorTechnologyType()
{
HANDLE hPhysicalMonitor = physMons[0].hPhysicalMonitor;
Expand All @@ -75,6 +79,7 @@ public void testGetMonitorTechnologyType()
Dxva2.INSTANCE.GetMonitorTechnologyType(hPhysicalMonitor, techType);
}

@Test
public void testGetMonitorCapabilities()
{
HANDLE hPhysicalMonitor = physMons[0].hPhysicalMonitor;
Expand All @@ -86,6 +91,7 @@ public void testGetMonitorCapabilities()
Dxva2.INSTANCE.GetMonitorCapabilities(hPhysicalMonitor, caps, temps);
}

@Test
public void testGetMonitorBrightness()
{
HANDLE hPhysicalMonitor = physMons[0].hPhysicalMonitor;
Expand All @@ -98,6 +104,7 @@ public void testGetMonitorBrightness()
Dxva2.INSTANCE.GetMonitorBrightness(hPhysicalMonitor, pdwMinimumBrightness, pdwCurrentBrightness, pdwMaximumBrightness);
}

@Test
public void testGetMonitorContrast()
{
HANDLE hPhysicalMonitor = physMons[0].hPhysicalMonitor;
Expand All @@ -110,6 +117,7 @@ public void testGetMonitorContrast()
Dxva2.INSTANCE.GetMonitorContrast(hPhysicalMonitor, pdwMinimumContrast, pdwCurrentContrast, pdwMaximumContrast);
}

@Test
public void testGetMonitorColorTemperature()
{
HANDLE hPhysicalMonitor = physMons[0].hPhysicalMonitor;
Expand All @@ -120,6 +128,7 @@ public void testGetMonitorColorTemperature()
Dxva2.INSTANCE.GetMonitorColorTemperature(hPhysicalMonitor, pctCurrentColorTemperature);
}

@Test
public void testCapabilitiesRequestAndCapabilitiesReply()
{
HANDLE hPhysicalMonitor = physMons[0].hPhysicalMonitor;
Expand All @@ -134,6 +143,7 @@ public void testCapabilitiesRequestAndCapabilitiesReply()
Dxva2.INSTANCE.CapabilitiesRequestAndCapabilitiesReply(hPhysicalMonitor, pszASCIICapabilitiesString, capStrLen);
}

@Test
public void testGetMonitorDisplayAreaPosition()
{
HANDLE hPhysicalMonitor = physMons[0].hPhysicalMonitor;
Expand All @@ -147,6 +157,7 @@ public void testGetMonitorDisplayAreaPosition()
Dxva2.INSTANCE.GetMonitorDisplayAreaPosition(hPhysicalMonitor, ptPositionType, pdwMinimumPosition, pdwCurrentPosition, pdwMaximumPosition);
}

@Test
public void testGetMonitorDisplayAreaSize()
{
HANDLE hPhysicalMonitor = physMons[0].hPhysicalMonitor;
Expand All @@ -160,6 +171,7 @@ public void testGetMonitorDisplayAreaSize()
Dxva2.INSTANCE.GetMonitorDisplayAreaSize(hPhysicalMonitor, ptSizeType, pdwMinimumSize, pdwCurrentSize, pdwMaximumSize);
}

@Test
public void testGetMonitorRedGreenOrBlueGain()
{
HANDLE hPhysicalMonitor = physMons[0].hPhysicalMonitor;
Expand All @@ -173,6 +185,7 @@ public void testGetMonitorRedGreenOrBlueGain()
Dxva2.INSTANCE.GetMonitorRedGreenOrBlueGain(hPhysicalMonitor, ptGainType, pdwMinimumGain, pdwCurrentGain, pdwMaximumGain);
}

@Test
public void testGetMonitorRedGreenOrBlueDrive()
{
HANDLE hPhysicalMonitor = physMons[0].hPhysicalMonitor;
Expand All @@ -186,6 +199,7 @@ public void testGetMonitorRedGreenOrBlueDrive()
Dxva2.INSTANCE.GetMonitorRedGreenOrBlueDrive(hPhysicalMonitor, ptDriveType, pdwMinimumDrive, pdwCurrentDrive, pdwMaximumDrive);
}

@Test
public void testGetTimingReport()
{
HANDLE hPhysicalMonitor = physMons[0].hPhysicalMonitor;
Expand Down
Binary file added lib/hamcrest-core-1.3.jar
Binary file not shown.

0 comments on commit 1c7e616

Please sign in to comment.