libept
desktop.test.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 #include <ept/config.h>
3 #include <ept/core/desktop.h>
4 #include <ept/core/list.h>
5 #include <ept/test.h>
6 
7 using namespace ept::core;
8 
9 struct TestDesktop {
12 
13  TestDesktop() : desk( TEST_ENV_DIR "desktop" ) {}
14 
15  template< desktop::PropertyId P, typename L >
16  void checkIteration2( int c, const char **check, L l ) {
17  int i = 0;
18  while ( !l.empty() ) {
19  assert_eq( l.head().template get< P >(), check[ i ] );
20  l = l.tail();
21  ++ i;
22  }
23  assert_eq( i, c );
24  }
25 
26  template< desktop::PropertyId P, typename L >
27  void checkIteration( int c, const char **check, L l ) {
28  checkIteration2< P >( c, check, list::sort( l ) );
29  }
30 
31  Test iteration() {
32  const char *check[] = { "Kdict", "foo", "XQF", "X-Server" };
33  checkIteration< desktop::Name >(
34  4, check, desk.list< desktop::Name >() );
35  }
36 
37  Test groupProperty() {
38  const char *check[] = {
39  "{ KDE, Qt, Utility }",
40  "{ KDE, Qt, Utility }",
41  "{ Application, Game, X-SuSE-Core-Game }",
42  "{ KDE, Qt, X-KDE-information }",
43  };
44  checkIteration< desktop::Group >(
45  4, check, desk.list< desktop::Name >() );
46  }
47 
48  Test groups() {
49  const char *check[] = { "Kdict", "foo" };
50  checkIteration< desktop::Name >(
51  2, check, desk.group( "{ KDE, Qt, Utility }" ) );
52  }
53 
54  Test groupList() {
55  std::string check[] = {
56  "{ Application, Game, X-SuSE-Core-Game }",
57  "{ KDE, Qt, Utility }",
58  "{ KDE, Qt, X-KDE-information }",
59  };
60 
61  assert_list_eq( desk.groupList(), check );
62  }
63 
64  Test emptyGroupList() {
66  assert( l.empty() );
67  }
68 };