-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added unit tests for v2 and cleaned up code
- Loading branch information
William Taylor
committed
May 2, 2016
1 parent
3dbb625
commit 03b1fa1
Showing
11 changed files
with
396 additions
and
236 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
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
|
||
#include "CppUnitTest.h" | ||
#include "Tests.h" | ||
|
||
using namespace Microsoft::VisualStudio::CppUnitTestFramework; | ||
|
||
auto timeout = [](Uint32 interval, void * ptr) -> Uint32 { | ||
SDL_Event e; | ||
e.type = SDL_QUIT; | ||
SDL_PushEvent(&e); | ||
return 0; | ||
}; | ||
|
||
namespace WPLTests | ||
{ | ||
TEST_CLASS(StateTests) | ||
{ | ||
public: | ||
TEST_METHOD(PlayTest) | ||
{ | ||
SDL_Init(SDL_INIT_VIDEO); | ||
SDL_Window * window = SDL_CreateWindow("Playback Demo", 100, 100, 800, 500, SDL_WINDOW_SHOWN); | ||
|
||
SDL_SysWMinfo wmInfo; | ||
SDL_VERSION(&wmInfo.version); | ||
SDL_GetWindowWMInfo(window, &wmInfo); | ||
|
||
wpl::VideoPlayer videoPlayer(wmInfo.info.win.window); | ||
|
||
Assert::IsTrue(videoPlayer.openVideo("demo.wmv"), L"Error didnt load file"); | ||
Assert::IsTrue(videoPlayer.play(), L"Error couldnt play file"); | ||
|
||
SDL_DestroyWindow(window); | ||
SDL_Quit(); | ||
} | ||
|
||
TEST_METHOD(PauseTest) | ||
{ | ||
SDL_Init(SDL_INIT_VIDEO); | ||
SDL_Window * window = SDL_CreateWindow("", 100, 100, 800, 500, SDL_WINDOW_SHOWN); | ||
|
||
SDL_SysWMinfo wmInfo; | ||
SDL_VERSION(&wmInfo.version); | ||
SDL_GetWindowWMInfo(window, &wmInfo); | ||
|
||
wpl::VideoPlayer videoPlayer(wmInfo.info.win.window); | ||
|
||
Assert::IsTrue(videoPlayer.openVideo("demo.wmv"), L"Error didnt load file"); | ||
Assert::IsTrue(videoPlayer.play(), L"Error couldnt play file"); | ||
Assert::IsTrue(videoPlayer.pause(), L"Error couldnt pause file"); | ||
|
||
SDL_DestroyWindow(window); | ||
SDL_Quit(); | ||
} | ||
|
||
TEST_METHOD(Stoptest) | ||
{ | ||
SDL_Init(SDL_INIT_VIDEO); | ||
SDL_Window * window = SDL_CreateWindow("", 100, 100, 800, 500, SDL_WINDOW_SHOWN); | ||
|
||
SDL_SysWMinfo wmInfo; | ||
SDL_VERSION(&wmInfo.version); | ||
SDL_GetWindowWMInfo(window, &wmInfo); | ||
|
||
wpl::VideoPlayer videoPlayer(wmInfo.info.win.window); | ||
|
||
Assert::IsTrue(videoPlayer.openVideo("demo.wmv"), L"Error didnt load file"); | ||
Assert::IsTrue(videoPlayer.play(), L"Error couldnt play file"); | ||
Assert::IsTrue(videoPlayer.stop(), L"Error couldnt stop file"); | ||
|
||
SDL_DestroyWindow(window); | ||
SDL_Quit(); | ||
} | ||
|
||
TEST_METHOD(FinishedTest) | ||
{ | ||
SDL_Init(SDL_INIT_VIDEO); | ||
SDL_Window * window = SDL_CreateWindow("", 100, 100, 800, 500, SDL_WINDOW_SHOWN); | ||
|
||
SDL_SysWMinfo wmInfo; | ||
SDL_VERSION(&wmInfo.version); | ||
SDL_GetWindowWMInfo(window, &wmInfo); | ||
|
||
wpl::VideoPlayer videoPlayer(wmInfo.info.win.window); | ||
|
||
Assert::IsTrue(videoPlayer.openVideo("demo.wmv"), L"Error didnt load file"); | ||
Assert::IsTrue(videoPlayer.play(), L"Error couldnt play file"); | ||
|
||
SDL_AddTimer(PLAYBACK_TIMEOUT, timeout, nullptr); | ||
|
||
auto quit = false; | ||
|
||
while (!quit) { | ||
SDL_Event event; | ||
while (SDL_PollEvent(&event)) { | ||
if (event.type == SDL_QUIT) { | ||
Assert::Fail(); | ||
quit = true; | ||
} | ||
} | ||
|
||
if (videoPlayer.hasFinished()) | ||
quit = true; | ||
} | ||
|
||
SDL_DestroyWindow(window); | ||
SDL_Quit(); | ||
} | ||
}; | ||
} |
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,25 @@ | ||
|
||
#pragma once | ||
|
||
#include <windows.h>//different header file in linux | ||
#include <future> | ||
|
||
#include "../WPL/WPL.h" | ||
#include "../WPL.Sample/SDL2/SDL.h" | ||
#include "../WPL.Sample/SDL2/SDL_syswm.h" | ||
|
||
#pragma comment(lib, "../WPL.Sample/SDL2/SDL2main.lib") | ||
#pragma comment(lib, "../WPL.Sample/SDL2/SDL2.lib") | ||
#pragma comment(lib, "WPL.lib") | ||
|
||
#define PLAYBACK_TIMEOUT 15000 | ||
|
||
template <typename... ParamTypes> | ||
void setTimeout(int milliseconds, std::function<void()> func) | ||
{ | ||
std::async(std::launch::async, [=]() | ||
{ | ||
Sleep(milliseconds); | ||
func(); | ||
}); | ||
}; |
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
Oops, something went wrong.