Add test for streaming with BASS
This commit is contained in:
		
							parent
							
								
									337b056400
								
							
						
					
					
						commit
						1fc6c85568
					
				@ -1,8 +1,14 @@
 | 
			
		||||
Running tests requires Catch2 and cmake
 | 
			
		||||
Running tests requires Catch2 and cmake.  libs are assumed to be in
 | 
			
		||||
the same directory as the executable
 | 
			
		||||
 | 
			
		||||
```sh
 | 
			
		||||
mkdir cbuild && cd cbuild
 | 
			
		||||
cmake ..
 | 
			
		||||
make test
 | 
			
		||||
 | 
			
		||||
# usage: run all tests
 | 
			
		||||
./test/test
 | 
			
		||||
 | 
			
		||||
# usage: Optionally specify tests and success verbosity
 | 
			
		||||
./test/test [bass] --success
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
@ -1,6 +1,7 @@
 | 
			
		||||
find_package(Qt5 COMPONENTS Core Gui REQUIRED)
 | 
			
		||||
find_package(Catch2 REQUIRED)
 | 
			
		||||
 | 
			
		||||
add_executable(test test_aopacket.cpp test_caseloading.cpp test_apng.cpp ../include/aopacket.h ../src/aopacket.cpp)
 | 
			
		||||
add_executable(test test_aopacket.cpp test_caseloading.cpp test_apng.cpp test_bass.cpp ../include/aopacket.h ../src/aopacket.cpp)
 | 
			
		||||
target_include_directories(test PRIVATE ../include)
 | 
			
		||||
target_link_libraries(test PRIVATE Qt5::Core Qt5::Gui Catch2::Catch2)
 | 
			
		||||
target_link_directories(test PRIVATE ../lib)
 | 
			
		||||
target_link_libraries(test PRIVATE Qt5::Core Qt5::Gui Catch2::Catch2 bass)
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										28
									
								
								test/test_bass.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								test/test_bass.cpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,28 @@
 | 
			
		||||
#include <iostream>
 | 
			
		||||
#include <cstring>
 | 
			
		||||
 | 
			
		||||
#include <catch2/catch.hpp>
 | 
			
		||||
#include <QString>
 | 
			
		||||
 | 
			
		||||
#include "bass.h"
 | 
			
		||||
 | 
			
		||||
TEST_CASE("BASS URL streaming", "[bass]") {
 | 
			
		||||
  // Sample
 | 
			
		||||
  QString url = "https://raw.githubusercontent.com/skyedeving/aocharedit/master/Attorney%20Online%20Character%20Editor/Resources/about.mp3";
 | 
			
		||||
  BASS_Init(-1, 44100, 0, 0, nullptr);
 | 
			
		||||
#ifdef _WIN32
 | 
			
		||||
  HSTREAM stream = BASS_StreamCreateURL(url.toWStdString().c_str(), 0, BASS_STREAM_STATUS, nullptr, 0);
 | 
			
		||||
#else
 | 
			
		||||
  HSTREAM stream = BASS_StreamCreateURL(url.toStdString().c_str(), 0, BASS_STREAM_STATUS, nullptr, 0);
 | 
			
		||||
#endif
 | 
			
		||||
  const char *tags = BASS_ChannelGetTags(stream, BASS_TAG_HTTP);
 | 
			
		||||
  if (tags) {
 | 
			
		||||
    while(*tags) {
 | 
			
		||||
      UNSCOPED_INFO(tags);
 | 
			
		||||
      tags += strlen(tags) + 1;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  REQUIRE(stream != 0);
 | 
			
		||||
  REQUIRE(BASS_ChannelPlay(stream, TRUE) == TRUE);
 | 
			
		||||
  // while (BASS_ChannelIsActive(stream) != BASS_ACTIVE_STOPPED);
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user