-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
381 additions
and
207 deletions.
There are no files selected for viewing
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
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
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
64 changes: 64 additions & 0 deletions
64
webcam-capture/src/test/java/com/github/sarxos/webcam/WebcamLockTest.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,64 @@ | ||
package com.github.sarxos.webcam; | ||
|
||
import org.assertj.core.api.Assertions; | ||
import org.easymock.EasyMock; | ||
import org.easymock.EasyMockRunner; | ||
import org.easymock.EasyMockSupport; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
|
||
/** | ||
* This test case is to cover {@link WebcamLock} class. | ||
* | ||
* @author Bartosz Firyn (sarxos) | ||
*/ | ||
@RunWith(EasyMockRunner.class) | ||
public class WebcamLockTest extends EasyMockSupport { | ||
|
||
Webcam webcam; | ||
|
||
@Before | ||
public void before() { | ||
|
||
webcam = createNiceMock(Webcam.class); | ||
|
||
EasyMock | ||
.expect(webcam.getName()) | ||
.andReturn("test-webcam") | ||
.anyTimes(); | ||
|
||
replayAll(); | ||
} | ||
|
||
@Test | ||
public void test_lock() { | ||
|
||
WebcamLock lock = new WebcamLock(webcam); | ||
lock.lock(); | ||
|
||
Assertions | ||
.assertThat(lock.isLocked()) | ||
.isTrue(); | ||
|
||
lock.unlock(); | ||
|
||
Assertions | ||
.assertThat(lock.isLocked()) | ||
.isFalse(); | ||
} | ||
|
||
@Test | ||
public void test_lock2() { | ||
|
||
WebcamLock first = new WebcamLock(webcam); | ||
WebcamLock second = new WebcamLock(webcam); | ||
|
||
first.lock(); | ||
|
||
Assertions | ||
.assertThat(second.isLocked()) | ||
.isTrue(); | ||
} | ||
} |
Oops, something went wrong.