00001
00002 #include <ept/config.h>
00003 #include <ept/core/desktop.h>
00004 #include <ept/core/list.h>
00005 #include <ept/test.h>
00006
00007 using namespace ept::core;
00008
00009 struct TestDesktop {
00010 desktop::Source desk;
00011 ept::Token t;
00012
00013 TestDesktop() : desk( TEST_ENV_DIR "desktop" ) {}
00014
00015 template< desktop::PropertyId P, typename L >
00016 void checkIteration2( int c, const char **check, L l ) {
00017 int i = 0;
00018 while ( !l.empty() ) {
00019 assert_eq( l.head().template get< P >(), check[ i ] );
00020 l = l.tail();
00021 ++ i;
00022 }
00023 assert_eq( i, c );
00024 }
00025
00026 template< desktop::PropertyId P, typename L >
00027 void checkIteration( int c, const char **check, L l ) {
00028 checkIteration2< P >( c, check, list::sort( l ) );
00029 }
00030
00031 Test iteration() {
00032 const char *check[] = { "X-Server", "XQF", "foo", "Kdict" };
00033 checkIteration< desktop::Name >(
00034 4, check, desk.list< desktop::Name >() );
00035 }
00036
00037 Test groupProperty() {
00038 const char *check[] = {
00039 "{ KDE, Qt, X-KDE-information }",
00040 "{ Application, Game, X-SuSE-Core-Game }",
00041 "{ KDE, Qt, Utility }",
00042 "{ KDE, Qt, Utility }" };
00043 checkIteration< desktop::Group >(
00044 4, check, desk.list< desktop::Name >() );
00045 }
00046
00047 Test groups() {
00048 const char *check[] = { "foo", "Kdict" };
00049 checkIteration< desktop::Name >(
00050 2, check, desk.group( "{ KDE, Qt, Utility }" ) );
00051 }
00052
00053 Test groupList() {
00054 std::string check[] = {
00055 "{ Application, Game, X-SuSE-Core-Game }",
00056 "{ KDE, Qt, Utility }",
00057 "{ KDE, Qt, X-KDE-information }",
00058 };
00059
00060 assert_list_eq( desk.groupList(), check );
00061 }
00062
00063 Test emptyGroupList() {
00064 desktop::InternalList l;
00065 assert( l.empty() );
00066 }
00067 };