237
244
EXPECT_EQ (expectedModifierMask, modifierMask);
249
static const std::string emptyProfileName ("");
250
static const std::string globalTestProfileName ("test");
251
static const std::string globalGeneralProfileSection ("general");
252
static const std::string globalGeneralProfileSectionUnderscore ("general_");
253
static const std::string globalTestGeneralProfileSection (globalGeneralProfileSectionUnderscore + globalTestProfileName);
254
static const std::string globalGNOMEProfileSection ("gnome_session");
255
static const std::string globalKDE4ProfileSection ("kde4_session");
256
static const std::string globalKDE3ProfileSection ("kde_session");
257
static const std::string four ("4");
258
static const std::string trueStr ("true");
265
explicit TmpEnv (const char *env, const char *val) :
267
envRestoreVal (getenv (env))
272
setenv (env, val, TRUE);
278
setenv (envRestore, envRestoreVal, TRUE);
280
unsetenv (envRestore);
285
const char *envRestore;
286
const char *envRestoreVal;
289
const char * getConstCharFromCharacterWrapper (const CharacterWrapper &wrap)
297
operator<< (std::ostream &os, const CharacterWrapper &wrap)
299
return os << getConstCharFromCharacterWrapper (wrap);
303
operator== (const std::string &str, const CharacterWrapper &wrap)
305
return str == getConstCharFromCharacterWrapper (wrap);
308
class CCSUtilProfileSelection :
309
public ::testing::Test
313
CCSUtilProfileSelection () :
314
ccsEnv ("COMPIZ_CONFIG_PROFILE", NULL),
315
gnomeEnv ("GNOME_DESKTOP_SESSION_ID", NULL),
316
kde4Env ("KDE_SESSION_VERSION", NULL),
317
kdeEnv ("KDE_FULL_SESSION", NULL)
329
TEST_F (CCSUtilProfileSelection, OverrideWithName)
331
TmpEnv env ("COMPIZ_CONFIG_PROFILE", globalTestProfileName.c_str ());
332
CharacterWrapper sName (getSectionName ());
334
EXPECT_EQ (globalTestGeneralProfileSection, sName);
337
TEST_F (CCSUtilProfileSelection, OverrideWithNoName)
339
TmpEnv env ("COMPIZ_CONFIG_PROFILE", emptyProfileName.c_str ());
340
CharacterWrapper sName (getSectionName ());
342
EXPECT_EQ (globalGeneralProfileSection, sName);
345
TEST_F (CCSUtilProfileSelection, NoOverrideInGNOME)
347
TmpEnv env ("GNOME_DESKTOP_SESSION_ID", globalTestProfileName.c_str ());
348
CharacterWrapper sName (getSectionName ());
350
EXPECT_EQ (globalGNOMEProfileSection, sName);
353
TEST_F (CCSUtilProfileSelection, NoOverrideInKDE4)
355
TmpEnv env ("KDE_SESSION_VERSION", four.c_str ());
356
CharacterWrapper sName (getSectionName ());
358
EXPECT_EQ (globalKDE4ProfileSection, sName);
361
TEST_F (CCSUtilProfileSelection, NoOverrideInKDE3)
363
TmpEnv env ("KDE_FULL_SESSION", trueStr.c_str ());
364
CharacterWrapper sName (getSectionName ());
366
EXPECT_EQ (globalKDE3ProfileSection, sName);
369
TEST_F (CCSUtilProfileSelection, Fallback)
371
CharacterWrapper sName (getSectionName ());
373
EXPECT_EQ (globalGeneralProfileSection, sName);