Skip to content

Commit

Permalink
8177560: @headful key can be removed from the tests for JavaSound
Browse files Browse the repository at this point in the history
Backport-of: 0b9c38fa6ec2a64d00d244cbe161feb29963ab11
  • Loading branch information
mrserb committed Jan 30, 2023
1 parent 65b3bd9 commit 165ce6a
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 41 deletions.
15 changes: 9 additions & 6 deletions jdk/test/javax/sound/midi/Devices/InitializationHang.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -24,18 +24,21 @@
import java.awt.Toolkit;

import javax.sound.midi.MidiSystem;
import javax.sound.midi.MidiUnavailableException;

/**
* @test
* @bug 8068412
* @key headful
* @author Sergey Bylokhov
*/
public final class InitializationHang {

public static void main(final String[] argv) throws Exception {
MidiSystem.getReceiver();
Toolkit.getDefaultToolkit();
public static void main(final String[] argv) {
try {
MidiSystem.getReceiver();
Toolkit.getDefaultToolkit();
} catch (final MidiUnavailableException ignored) {
// the test is not applicable
}
}
}

19 changes: 13 additions & 6 deletions jdk/test/javax/sound/midi/Sequencer/SeqRecordDoesNotCopy.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -24,6 +24,7 @@
import javax.sound.midi.MidiEvent;
import javax.sound.midi.MidiMessage;
import javax.sound.midi.MidiSystem;
import javax.sound.midi.MidiUnavailableException;
import javax.sound.midi.Receiver;
import javax.sound.midi.Sequence;
import javax.sound.midi.Sequencer;
Expand All @@ -34,12 +35,18 @@
* @test
* @bug 5048381
* @summary Sequencer doesn't create distinct messages when recording events.
* @key headful
*/
public class SeqRecordDoesNotCopy {
public static void main(String argv[]) throws Exception {
Sequencer s = MidiSystem.getSequencer();
s.open();

public static void main(String argv[]) {
Sequencer s = null;
try {
s = MidiSystem.getSequencer();
s.open();
} catch (final MidiUnavailableException ignored) {
// the test is not applicable
return;
}
try {
Sequence seq = new Sequence(Sequence.PPQ, 384, 2);
s.setSequence(seq);
Expand Down Expand Up @@ -86,7 +93,7 @@ public static void main(String argv[]) throws Exception {
} catch (Exception e) {
System.out.println("Unexpected Exception: "+e);
//e.printStackTrace();
throw new Exception("Test FAILED!");
throw new RuntimeException("Test FAILED!");
} finally {
s.close();
}
Expand Down
19 changes: 13 additions & 6 deletions jdk/test/javax/sound/midi/Sequencer/SeqRecordsRealTimeEvents.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -24,6 +24,7 @@
import javax.sound.midi.MidiEvent;
import javax.sound.midi.MidiMessage;
import javax.sound.midi.MidiSystem;
import javax.sound.midi.MidiUnavailableException;
import javax.sound.midi.Receiver;
import javax.sound.midi.Sequence;
import javax.sound.midi.Sequencer;
Expand All @@ -34,12 +35,18 @@
* @test
* @bug 5048381
* @summary Sequencer records real time messages into the sequence
* @key headful
*/
public class SeqRecordsRealTimeEvents {
public static void main(String argv[]) throws Exception {
Sequencer s = MidiSystem.getSequencer();
s.open();

public static void main(String argv[]) {
Sequencer s = null;
try {
s = MidiSystem.getSequencer();
s.open();
} catch (final MidiUnavailableException ignored) {
// the test is not applicable
return;
}
try {
Sequence seq = new Sequence(Sequence.PPQ, 384, 2);
s.setSequence(seq);
Expand Down Expand Up @@ -90,7 +97,7 @@ public static void main(String argv[]) throws Exception {
} catch (Exception e) {
System.out.println("Unexpected Exception: "+e);
//e.printStackTrace();
throw new Exception("Test FAILED!");
throw new RuntimeException("Test FAILED!");
} finally {
s.close();
}
Expand Down
19 changes: 13 additions & 6 deletions jdk/test/javax/sound/midi/Sequencer/SeqStartRecording.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -22,25 +22,32 @@
*/

import javax.sound.midi.MidiSystem;
import javax.sound.midi.MidiUnavailableException;
import javax.sound.midi.Sequencer;

/**
* @test
* @bug 5001943
* @summary Sequencer.startRecording throws unexpected NPE
* @key headful
*/
public class SeqStartRecording {
public static void main(String argv[]) throws Exception {
Sequencer seq = MidiSystem.getSequencer();
seq.open();

public static void main(String argv[]) {
Sequencer seq = null;
try {
seq = MidiSystem.getSequencer();
seq.open();
} catch (final MidiUnavailableException ignored) {
// the test is not applicable
return;
}
try {
seq.startRecording();
System.out.println("Test passed.");
} catch (NullPointerException npe) {
System.out.println("Caught NPE: "+npe);
npe.printStackTrace();
throw new Exception("Test FAILED!");
throw new RuntimeException("Test FAILED!");
} catch (Exception e) {
System.out.println("Unexpected Exception: "+e);
e.printStackTrace();
Expand Down
12 changes: 7 additions & 5 deletions jdk/test/javax/sound/midi/Synthesizer/bug4685396.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2006, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -23,6 +23,7 @@

import javax.sound.midi.Instrument;
import javax.sound.midi.MidiSystem;
import javax.sound.midi.MidiUnavailableException;
import javax.sound.midi.Soundbank;
import javax.sound.midi.Synthesizer;

Expand All @@ -31,7 +32,6 @@
* @bug 4685396
* @summary Tests that Synthesizer.remapInstrument works
* @run main bug4685396
* @key headful
*/
public class bug4685396 {

Expand All @@ -49,8 +49,7 @@ static boolean test(
boolean reloadInstr, // reload all instruments?
boolean unloadFrom, // unload "from" instrument?
boolean unloadTo // unload "to" instrument?
) throws Exception
{
) throws MidiUnavailableException {
log("Starting test: reloadInstr=" + reloadInstr
+ ", unloadFrom=" + unloadFrom
+ ", unloadTo=" + unloadTo
Expand Down Expand Up @@ -164,14 +163,17 @@ static boolean runTest(
boolean success = false;
try {
success = test(reloadInstr, unloadFrom, unloadTo);
} catch (final MidiUnavailableException ignored) {
// the test is not applicable
success = true;
} catch (Exception ex) {
log("Exception: " + ex.toString());
}
cleanup();
return success;
}

public static void main(String args[]) throws Exception {
public static void main(String args[]) {
boolean failed = false;
if (!runTest(true, false, false))
failed = true;
Expand Down
3 changes: 1 addition & 2 deletions jdk/test/javax/sound/sampled/Clip/ClipCloseLoss.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -36,7 +36,6 @@
* @bug 4946913 8178403
* @summary DirectClip doesn't kill the thread correctly, sometimes
* @run main/othervm ClipCloseLoss
* @key headful
*/
public class ClipCloseLoss {
static int frameCount = 441000; // lets say 10 seconds
Expand Down
13 changes: 9 additions & 4 deletions jdk/test/javax/sound/sampled/Clip/bug5070081.java
Expand Up @@ -27,13 +27,13 @@
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Clip;
import javax.sound.sampled.DataLine;
import javax.sound.sampled.LineUnavailableException;

/*
* @test
* @bug 5070081
* @summary Tests that javax.sound.sampled.Clip does not loses position through
* stop/start
* @key headful
*/
public class bug5070081 {

Expand All @@ -45,10 +45,15 @@ public class bug5070081 {

static boolean test() throws Exception {
DataLine.Info info = new DataLine.Info(Clip.class, format);
Clip clip = (Clip)AudioSystem.getLine(info);
clip.open(format, soundData, 0, soundData.length);

Clip clip = null;
boolean bSuccess = true;
try {
clip = (Clip) AudioSystem.getLine(info);
clip.open(format, soundData, 0, soundData.length);
} catch (LineUnavailableException | IllegalArgumentException ignored) {
// the test is not applicable
return bSuccess;
}

long nLengthMS = clip.getMicrosecondLength()/1000;

Expand Down
7 changes: 3 additions & 4 deletions jdk/test/javax/sound/sampled/DataLine/LongFramePosition.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -30,7 +30,6 @@
* @test
* @bug 5049129
* @summary DataLine.getLongFramePosition
* @key headful
*/
public class LongFramePosition {

Expand Down Expand Up @@ -59,12 +58,12 @@ public static void main(String[] args) throws Exception {
} finally {
sdl.close();
}
} catch(LineUnavailableException e){
} catch (LineUnavailableException | IllegalArgumentException e) {
System.out.println(e);
System.out.println("Cannot execute test.");
return;
}
if (failed) throw new Exception("Test FAILED!");
if (failed) throw new RuntimeException("Test FAILED!");
System.out.println("Test Passed.");
}
}
3 changes: 1 addition & 2 deletions jdk/test/javax/sound/sampled/DirectAudio/bug6372428.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2006, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -34,7 +34,6 @@
* @summary playback and capture doesn't interrupt after terminating thread that
* calls start()
* @run main bug6372428
* @key headful
*/
public class bug6372428 {
public bug6372428() {
Expand Down

1 comment on commit 165ce6a

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.