libept
|
00001 // -*- C++ -*- 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[] = { "Kdict", "foo", "XQF", "X-Server" }; 00033 checkIteration< desktop::Name >( 00034 4, check, desk.list< desktop::Name >() ); 00035 } 00036 00037 Test groupProperty() { 00038 const char *check[] = { 00039 "{ KDE, Qt, Utility }", 00040 "{ KDE, Qt, Utility }", 00041 "{ Application, Game, X-SuSE-Core-Game }", 00042 "{ KDE, Qt, X-KDE-information }", 00043 }; 00044 checkIteration< desktop::Group >( 00045 4, check, desk.list< desktop::Name >() ); 00046 } 00047 00048 Test groups() { 00049 const char *check[] = { "Kdict", "foo" }; 00050 checkIteration< desktop::Name >( 00051 2, check, desk.group( "{ KDE, Qt, Utility }" ) ); 00052 } 00053 00054 Test groupList() { 00055 std::string check[] = { 00056 "{ Application, Game, X-SuSE-Core-Game }", 00057 "{ KDE, Qt, Utility }", 00058 "{ KDE, Qt, X-KDE-information }", 00059 }; 00060 00061 assert_list_eq( desk.groupList(), check ); 00062 } 00063 00064 Test emptyGroupList() { 00065 desktop::InternalList l; 00066 assert( l.empty() ); 00067 } 00068 };