Skip to content

Commit

Permalink
Merge pull request #2976 from xerus2000/test-profiles
Browse files Browse the repository at this point in the history
test: Use tempdir for broadcast profiles
  • Loading branch information
Holzhaus authored Aug 5, 2020
2 parents fdaa955 + d019812 commit 42fcb20
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions src/test/broadcastprofile_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,40 +42,39 @@ TEST(BroadcastProfileTest, SaveAndLoadXML) {
// Preliminary: set a discriminating value in one of the profile fields
QString streamName("unit testing in progress");

BroadcastProfile profile("Unit Testing Profile");
BroadcastProfile profile("Broadcast Profile test");
profile.setStreamName(streamName);

QString filename = profile.getProfileName() + QString(".bcp.xml");
QTemporaryDir tempDir;
ASSERT_TRUE(tempDir.isValid());
QString filename = tempDir.filePath(profile.getProfileName() + QString(".bcp.xml"));

// Call save() on a profile and assert it actually exists
QFile::remove(filename); // First, make sure it doesn't exists
profile.save(filename);
ASSERT_TRUE(QFile::exists(filename));

// Load XML file using static loadFromFile and assert
// the discriminating value is present
BroadcastProfilePtr savedProfile = BroadcastProfile::loadFromFile(filename);
ASSERT_NE(savedProfile, nullptr);
ASSERT_TRUE(savedProfile->getStreamName() == streamName);
EXPECT_NE(savedProfile, nullptr);
EXPECT_TRUE(savedProfile->getStreamName() == streamName);
}

TEST(BroadcastProfileTest, SaveAndLoadXMLDotName) {
QString profileName("profile has a dot. (in the name)");

QString profileName("broadcast profile has a dot. (in the name) test");
BroadcastProfile profile(profileName);

QString filename = profile.getProfileName() + QString(".bcp.xml");
QTemporaryDir tempDir;
ASSERT_TRUE(tempDir.isValid());
QString filename = tempDir.filePath(profile.getProfileName() + QString(".bcp.xml"));

// Call save() on a profile and assert it actually exists
QFile::remove(filename); // First, make sure it doesn't exists
profile.save(filename);
ASSERT_TRUE(QFile::exists(filename));

// Load XML file using static loadFromFile and assert
// the discriminating value is present
BroadcastProfilePtr savedProfile = BroadcastProfile::loadFromFile(filename);
ASSERT_NE(savedProfile, nullptr);
ASSERT_TRUE(savedProfile->getProfileName() == profileName);
EXPECT_NE(savedProfile, nullptr);
EXPECT_TRUE(savedProfile->getProfileName() == profileName);
}

TEST(BroadcastProfileTest, SetGetValues) {
Expand Down

0 comments on commit 42fcb20

Please sign in to comment.