queue: Remove old unit test
Also take a few moments to update the DESIGN. Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
b9e5ce3356
commit
f6306faac8
51
DESIGN
51
DESIGN
|
@ -1,16 +1,16 @@
|
|||
===============================================================================
|
||||
= =
|
||||
= Ocarina 6.0 =
|
||||
= Ocarina 6.1 =
|
||||
= =
|
||||
===============================================================================
|
||||
|
||||
Ocarina 6.0 is the 6th implementation of the Ocarina music player - a
|
||||
Ocarina 6.1 is the 6th implementation of the Ocarina music player - a
|
||||
lightweight, GTK+ based music player with all the features that I want.
|
||||
Improvements over the 5.x series will include the existence of both a design
|
||||
document (this file) and unit tests. This should make maintenance easier and
|
||||
help me stay focused.
|
||||
|
||||
Ocarina 6.0 will use Gstreamer 1.0 for audio playback, GTK-MM 3 for user
|
||||
Ocarina 6.1 will use Gstreamer 1.0 for audio playback, GTK-MM 3 for user
|
||||
interface development, and Taglib for extracting tags.
|
||||
|
||||
|
||||
|
@ -893,14 +893,14 @@ Queue:
|
|||
void del(Track *);
|
||||
void del(unsigned int);
|
||||
void updated(Track *);
|
||||
Track *next();
|
||||
|
||||
unsigned int size();
|
||||
const std::string size_str();
|
||||
const std::string length_str();
|
||||
|
||||
void sort(sort_t, bool, bool);
|
||||
|
||||
Track *next();
|
||||
void sort(sort_t, bool);
|
||||
Track *operator[](unsigned int);
|
||||
void track_selected(unsigned int);
|
||||
};
|
||||
|
||||
|
@ -946,22 +946,6 @@ File Format:
|
|||
Find all indexes of the updated track and notify the UI that
|
||||
it has changed.
|
||||
|
||||
unsigned int Queue :: size();
|
||||
Return the number of tracks currently on the queue.
|
||||
|
||||
const std::string Queue :: size_str();
|
||||
Return the number of tracks currently on the queue, in string
|
||||
form.
|
||||
|
||||
const std::string Queue :: length_str();
|
||||
Return the remaining length of the queue in a human-readable
|
||||
format.
|
||||
|
||||
void Queue :: sort(sort_t field, bool ascending, bool reset);
|
||||
Add a new sort field to the end of the sort order, then
|
||||
resort the queue. If reset is set to true, clear the sorting
|
||||
list before appending.
|
||||
|
||||
Track *Queue :: next();
|
||||
Return the next track to play.
|
||||
|
||||
|
@ -981,6 +965,26 @@ File Format:
|
|||
del(_cur);
|
||||
return track;
|
||||
|
||||
unsigned int Queue :: size();
|
||||
Return the number of tracks currently on the queue.
|
||||
|
||||
const std::string Queue :: size_str();
|
||||
Return the number of tracks currently on the queue, in string
|
||||
form.
|
||||
|
||||
const std::string Queue :: length_str();
|
||||
Return the remaining length of the queue in a human-readable
|
||||
format.
|
||||
|
||||
void Queue :: sort(sort_t field, bool reset);
|
||||
If the field is already in the sort order, toggle its
|
||||
ascending value. Otherwise, add a new sort field to the end
|
||||
of the sort order with ascending set to true. If reset is set
|
||||
to true, clear the sorting list before appending.
|
||||
|
||||
Track *Queue :: operator[](unsigned int i);
|
||||
Return the track and index i.
|
||||
|
||||
void Queue :: track_selected(unsigned int queue_id);
|
||||
Set _cur to queue_id. If PQ_REPEAT is not set, remove the
|
||||
track from the queue.
|
||||
|
@ -992,7 +996,6 @@ File Format:
|
|||
|
||||
|
||||
|
||||
|
||||
- library queue should be set to the default sort order
|
||||
The default sort order is (SORT_ARTIST, true),
|
||||
(SORT_YEAR, true), (SORT_TRACK, true).
|
||||
|
@ -1100,7 +1103,7 @@ Library: (lib/library.cpp)
|
|||
|
||||
Playlists: (lib/playlist.cpp)
|
||||
Playlists are a new feature in Ocarina 6 and are modeled after Gmail
|
||||
labels. Ocarina 6.0 will support two different playlists that the
|
||||
labels. Ocarina 6.1 will support two different playlists that the
|
||||
user can add tracks to: banned and favorites.
|
||||
|
||||
Future releases will add support for more playlists.
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
#!/usr/bin/python
|
||||
Import("Test", "CONFIG")
|
||||
|
||||
CONFIG.PLAYQUEUE = True
|
||||
|
||||
Test("playqueue", "playqueue.cpp")
|
|
@ -1,222 +0,0 @@
|
|||
/*
|
||||
* Copyright 2013 (c) Anna Schumaker.
|
||||
*/
|
||||
#include <idle.h>
|
||||
#include <playqueue.h>
|
||||
#include <print.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string>
|
||||
|
||||
void test_flags(const std :: string &test, Playqueue &pqueue, unsigned int expected)
|
||||
{
|
||||
print("Test %s: ", test.c_str());
|
||||
if (pqueue.get_flags() == expected)
|
||||
print("SUCCESS\n");
|
||||
else
|
||||
print("FAILED\n");
|
||||
}
|
||||
|
||||
void test_add_tracks(const std :: string & test, Playqueue &pqueue,
|
||||
unsigned int start, unsigned int end)
|
||||
{
|
||||
bool passed = true;
|
||||
print("Test %s: ", test.c_str());
|
||||
for (unsigned int i = start; i <= end; i++) {
|
||||
if (pqueue.add(i) != (i - start))
|
||||
passed = false;
|
||||
}
|
||||
|
||||
if (passed == true)
|
||||
print("SUCCESS\n");
|
||||
else
|
||||
print("FAILED\n");
|
||||
}
|
||||
|
||||
void test_add_tracks_front(const std :: string &test, Playqueue &pqueue,
|
||||
unsigned int n)
|
||||
{
|
||||
bool passed = true;
|
||||
|
||||
print("Test %s: ", test.c_str());
|
||||
for (unsigned int i = 0; i < n; i++) {
|
||||
if (pqueue.add_front(i) != 0)
|
||||
passed = false;
|
||||
}
|
||||
|
||||
if (passed == true)
|
||||
print("SUCCESS\n");
|
||||
else
|
||||
print("FAILED\n");
|
||||
}
|
||||
|
||||
void test_rm_tracks(const std :: string & test, Playqueue & pqueue, unsigned int n)
|
||||
{
|
||||
unsigned int size = pqueue.size();
|
||||
unsigned int expected = size - n;
|
||||
|
||||
print("Test %s: ", test.c_str());
|
||||
|
||||
for (unsigned int i = 0; i < n; i++)
|
||||
pqueue.del(i);
|
||||
|
||||
if (pqueue.size() == expected)
|
||||
print("SUCCESS\n");
|
||||
else
|
||||
print("FAILED\n");
|
||||
}
|
||||
|
||||
void test_pqueue_status(const std :: string &test, Playqueue &pqueue)
|
||||
{
|
||||
print("Test %s: size: %u, length: %u\n", test.c_str(),
|
||||
pqueue.size(), pqueue.get_length());
|
||||
}
|
||||
|
||||
/* Test flag setting / unsetting / getting */
|
||||
void test_0()
|
||||
{
|
||||
Playqueue pqueue(PQ_ENABLED);
|
||||
|
||||
test_flags("0a", pqueue, PQ_ENABLED);
|
||||
pqueue.set_flag(PQ_RANDOM);
|
||||
test_flags("0b", pqueue, PQ_ENABLED | PQ_RANDOM);
|
||||
pqueue.set_flag(PQ_ENABLED);
|
||||
test_flags("0c", pqueue, PQ_ENABLED | PQ_RANDOM);
|
||||
pqueue.unset_flag(PQ_ENABLED);
|
||||
test_flags("0d", pqueue, PQ_RANDOM);
|
||||
pqueue.unset_flag(PQ_RANDOM);
|
||||
test_flags("0f", pqueue, 0);
|
||||
print("\n");
|
||||
}
|
||||
|
||||
/* Test adding / deleting / size queries */
|
||||
void test_1()
|
||||
{
|
||||
Playqueue pqueue(PQ_ENABLED);
|
||||
test_add_tracks("1a", pqueue, 10, 49);
|
||||
test_pqueue_status("1b", pqueue);
|
||||
test_rm_tracks("1c", pqueue, 10);
|
||||
test_pqueue_status("1d", pqueue);
|
||||
test_add_tracks_front("1e", pqueue, 5);
|
||||
test_pqueue_status("1f", pqueue);
|
||||
print("\n");
|
||||
}
|
||||
|
||||
/* Test read / write */
|
||||
void test_2()
|
||||
{
|
||||
Playqueue pqueue(PQ_ENABLED);
|
||||
Playqueue pqueue2(PQ_ENABLED);
|
||||
|
||||
File f("pqueue.lst", FILE_TYPE_DATA);
|
||||
|
||||
pqueue.set_flag(PQ_RANDOM);
|
||||
test_add_tracks("2a", pqueue, 0, 99);
|
||||
|
||||
f.open(OPEN_WRITE);
|
||||
pqueue.write(f);
|
||||
f.close();
|
||||
|
||||
f.open(OPEN_READ);
|
||||
pqueue2.read(f);
|
||||
f.close();
|
||||
|
||||
print("Test 2b: ");
|
||||
if (pqueue.get_flags() != pqueue2.get_flags()) {
|
||||
print("FAILED: flag mismatch\n");
|
||||
return;
|
||||
} else if (pqueue.size() != pqueue2.size()) {
|
||||
print("FAILED: size mismatch\n");
|
||||
return;
|
||||
}
|
||||
|
||||
print("SUCCESS\n\n");
|
||||
}
|
||||
|
||||
/* Sequential next() without removing tracks */
|
||||
void test_3()
|
||||
{
|
||||
Playqueue pqueue(PQ_ENABLED);
|
||||
pqueue.set_flag(PQ_REPEAT);
|
||||
test_add_tracks("3a", pqueue, 0, 15);
|
||||
for (unsigned int i = 0; i < 25; i++) {
|
||||
print("Selecting id: %u\n", pqueue.next());
|
||||
if (i == 4)
|
||||
pqueue.set_cur(0);
|
||||
}
|
||||
test_pqueue_status("3b", pqueue);
|
||||
print("\n");
|
||||
}
|
||||
|
||||
/* Sequential next() with removal */
|
||||
void test_4()
|
||||
{
|
||||
Playqueue pqueue(PQ_ENABLED);
|
||||
test_add_tracks("4a", pqueue, 0, 15);
|
||||
while (pqueue.size() > 0)
|
||||
print("Selecting id: %u\n", pqueue.next());
|
||||
test_pqueue_status("4b", pqueue);
|
||||
print("\n");
|
||||
}
|
||||
|
||||
/* Random next() without removing tracks */
|
||||
void test_5()
|
||||
{
|
||||
Playqueue pqueue(PQ_ENABLED);
|
||||
pqueue.set_flag(PQ_RANDOM);
|
||||
pqueue.set_flag(PQ_REPEAT);
|
||||
test_add_tracks("5a", pqueue, 0, 15);
|
||||
for (unsigned int i = 0; i < 30; i++)
|
||||
print("Selecting id: %u\n", pqueue.next());
|
||||
test_pqueue_status("5b", pqueue);
|
||||
print("\n");
|
||||
}
|
||||
|
||||
/* Random next() with removal */
|
||||
void test_6()
|
||||
{
|
||||
Playqueue pqueue(PQ_ENABLED);
|
||||
pqueue.set_flag(PQ_RANDOM);
|
||||
test_add_tracks("6a", pqueue, 0, 15);
|
||||
while (pqueue.size() > 0)
|
||||
print("Selecting id: %u\n", pqueue.next());
|
||||
test_pqueue_status("6b", pqueue);
|
||||
print("\n");
|
||||
}
|
||||
|
||||
void test_7()
|
||||
{
|
||||
char test[] = "7a";
|
||||
Playqueue pqueue(PQ_ENABLED);
|
||||
|
||||
for (unsigned int i = 0; i < 60; i++)
|
||||
pqueue.add(i % 15);
|
||||
test_pqueue_status(test, pqueue);
|
||||
|
||||
for (unsigned int i = 0; i < 15; i++) {
|
||||
pqueue.del_track(i);
|
||||
if ((i + 1) % 3 == 0) {
|
||||
test[1]++;
|
||||
test_pqueue_status(test, pqueue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
srand(42);
|
||||
library :: init();
|
||||
library :: reset();
|
||||
library :: add_path("/tmp/library/0");
|
||||
while (idle :: run_task());
|
||||
|
||||
test_0();
|
||||
test_1();
|
||||
test_2();
|
||||
test_3();
|
||||
test_4();
|
||||
test_5();
|
||||
test_6();
|
||||
test_7();
|
||||
return 0;
|
||||
}
|
|
@ -1,121 +0,0 @@
|
|||
Test 0a: SUCCESS
|
||||
Test 0b: SUCCESS
|
||||
Test 0c: SUCCESS
|
||||
Test 0d: SUCCESS
|
||||
Test 0f: SUCCESS
|
||||
|
||||
Test 1a: SUCCESS
|
||||
Test 1b: size: 40, length: 5648
|
||||
Test 1c: SUCCESS
|
||||
Test 1d: size: 30, length: 5284
|
||||
Test 1e: SUCCESS
|
||||
Test 1f: size: 35, length: 6015
|
||||
|
||||
Test 2a: SUCCESS
|
||||
Test 2b: SUCCESS
|
||||
|
||||
Test 3a: SUCCESS
|
||||
Selecting id: 0
|
||||
Selecting id: 1
|
||||
Selecting id: 2
|
||||
Selecting id: 3
|
||||
Selecting id: 4
|
||||
Selecting id: 1
|
||||
Selecting id: 2
|
||||
Selecting id: 3
|
||||
Selecting id: 4
|
||||
Selecting id: 5
|
||||
Selecting id: 6
|
||||
Selecting id: 7
|
||||
Selecting id: 8
|
||||
Selecting id: 9
|
||||
Selecting id: 10
|
||||
Selecting id: 11
|
||||
Selecting id: 12
|
||||
Selecting id: 13
|
||||
Selecting id: 14
|
||||
Selecting id: 15
|
||||
Selecting id: 0
|
||||
Selecting id: 1
|
||||
Selecting id: 2
|
||||
Selecting id: 3
|
||||
Selecting id: 4
|
||||
Test 3b: size: 16, length: 2153
|
||||
|
||||
Test 4a: SUCCESS
|
||||
Selecting id: 0
|
||||
Selecting id: 1
|
||||
Selecting id: 2
|
||||
Selecting id: 3
|
||||
Selecting id: 4
|
||||
Selecting id: 5
|
||||
Selecting id: 6
|
||||
Selecting id: 7
|
||||
Selecting id: 8
|
||||
Selecting id: 9
|
||||
Selecting id: 10
|
||||
Selecting id: 11
|
||||
Selecting id: 12
|
||||
Selecting id: 13
|
||||
Selecting id: 14
|
||||
Selecting id: 15
|
||||
Test 4b: size: 0, length: 0
|
||||
|
||||
Test 5a: SUCCESS
|
||||
Selecting id: 6
|
||||
Selecting id: 11
|
||||
Selecting id: 13
|
||||
Selecting id: 15
|
||||
Selecting id: 4
|
||||
Selecting id: 11
|
||||
Selecting id: 1
|
||||
Selecting id: 6
|
||||
Selecting id: 14
|
||||
Selecting id: 6
|
||||
Selecting id: 9
|
||||
Selecting id: 1
|
||||
Selecting id: 7
|
||||
Selecting id: 8
|
||||
Selecting id: 9
|
||||
Selecting id: 12
|
||||
Selecting id: 1
|
||||
Selecting id: 2
|
||||
Selecting id: 5
|
||||
Selecting id: 9
|
||||
Selecting id: 13
|
||||
Selecting id: 14
|
||||
Selecting id: 0
|
||||
Selecting id: 2
|
||||
Selecting id: 10
|
||||
Selecting id: 14
|
||||
Selecting id: 0
|
||||
Selecting id: 1
|
||||
Selecting id: 7
|
||||
Selecting id: 8
|
||||
Test 5b: size: 16, length: 2153
|
||||
|
||||
Test 6a: SUCCESS
|
||||
Selecting id: 1
|
||||
Selecting id: 2
|
||||
Selecting id: 4
|
||||
Selecting id: 9
|
||||
Selecting id: 10
|
||||
Selecting id: 11
|
||||
Selecting id: 0
|
||||
Selecting id: 5
|
||||
Selecting id: 7
|
||||
Selecting id: 8
|
||||
Selecting id: 13
|
||||
Selecting id: 15
|
||||
Selecting id: 6
|
||||
Selecting id: 12
|
||||
Selecting id: 14
|
||||
Selecting id: 3
|
||||
Test 6b: size: 0, length: 0
|
||||
|
||||
Test 7a: size: 60, length: 8572
|
||||
Test 7b: size: 48, length: 8288
|
||||
Test 7c: size: 36, length: 5608
|
||||
Test 7d: size: 24, length: 2964
|
||||
Test 7e: size: 12, length: 2644
|
||||
Test 7f: size: 0, length: 0
|
Loading…
Reference in New Issue