Răsfoiți Sursa

Check track is closed in track test

Paul-Louis Ageneau 3 ani în urmă
părinte
comite
ffc137ac80
1 a modificat fișierele cu 11 adăugiri și 2 ștergeri
  1. 11 2
      test/track.cpp

+ 11 - 2
test/track.cpp

@@ -82,12 +82,18 @@ void test_track() {
 	shared_ptr<Track> t2;
 	shared_ptr<Track> t2;
 	string newTrackMid;
 	string newTrackMid;
 	pc2.onTrack([&t2, &newTrackMid](shared_ptr<Track> t) {
 	pc2.onTrack([&t2, &newTrackMid](shared_ptr<Track> t) {
-		cout << "Track 2: Received with mid \"" << t->mid() << "\"" << endl;
-		if (t->mid() != newTrackMid) {
+		string mid = t->mid();
+		cout << "Track 2: Received track with mid \"" << mid << "\"" << endl;
+		if (mid != newTrackMid) {
 			cerr << "Wrong track mid" << endl;
 			cerr << "Wrong track mid" << endl;
 			return;
 			return;
 		}
 		}
 
 
+		t->onOpen([mid]() { cout << "Track 2: Track with mid \"" << mid << "\" is open" << endl; });
+
+		t->onClosed(
+		    [mid]() { cout << "Track 2: Track with mid \"" << mid << "\" is closed" << endl; });
+
 		std::atomic_store(&t2, t);
 		std::atomic_store(&t2, t);
 	});
 	});
 
 
@@ -131,5 +137,8 @@ void test_track() {
 	pc2.close();
 	pc2.close();
 	this_thread::sleep_for(1s);
 	this_thread::sleep_for(1s);
 
 
+	if (!t1->isClosed() || !t2->isClosed())
+		throw runtime_error("Track is not closed");
+
 	cout << "Success" << endl;
 	cout << "Success" << endl;
 }
 }