Merge lp:~compiz-team/compiz/compiz.fix_1080989 into lp:compiz/0.9.9

Proposed by Sam Spilsbury
Status: Merged
Approved by: Daniel van Vugt
Approved revision: 3478
Merged at revision: 3477
Proposed branch: lp:~compiz-team/compiz/compiz.fix_1080989
Merge into: lp:compiz/0.9.9
Diff against target: 234 lines (+181/-4)
3 files modified
compizconfig/libcompizconfig/src/ccs-config-private.h (+32/-0)
compizconfig/libcompizconfig/src/config.c (+12/-4)
compizconfig/libcompizconfig/tests/compizconfig_test_ccs_util.cpp (+137/-0)
To merge this branch: bzr merge lp:~compiz-team/compiz/compiz.fix_1080989
Reviewer Review Type Date Requested Status
Daniel van Vugt Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+135173@code.launchpad.net

This proposal supersedes a proposal from 2012-11-20.

Commit message

Fix various test failures caused by not controlling the environment variable
COMPIZ_CONFIG_PROFILE. (LP: #1070817) (LP: #1077787)

Description of the change

If the user overrides COMPIZ_CONFIG_PROFILE with an empty string, it probably
means that they meant to force the use of the general profile, since it
isn't meant to be set otherwise. Add tests for the new behaviour.

(LP: #1080989)

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

I think this is unreadable:
TEST_F (CCSUtilProfileSelectionTest, TestOverrideCompizConfigProfileWithNameReturnsGeneralUnderscoreName)

Also note the gtest TEST macros insert the word Test so using "Test" in the parameters is probably redundant. For example:
    TEST (Hello, World)
generates:
    Hello_World_Test

Revision history for this message
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

I can't reproduce anything like bug 1080989 to verify. But I can see that this seems to fix bug 1070817. Can we make it bug 1070817 instead or are they separate?

Also, the copyright header on new files should be one of your own :)

review: Needs Fixing
Revision history for this message
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

I think this fixes bug 1077787 too.

Revision history for this message
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

Ah. Run it in a gnome shell session to reproduce. In any case I can change
the name of the tests and the branches, we should probably rename the tests
to stop using the word "Test" for the reason you specify.
On 20/11/2012 5:34 PM, "Daniel van Vugt" <email address hidden>
wrote:

> Review: Needs Fixing
>
> I can't reproduce anything like bug 1080989 to verify. But I can see that
> this seems to fix bug 1070817. Can we make it bug 1070817 instead or are
> they separate?
>
> Also, the copyright header on new files should be one of your own :)
> --
>
> https://code.launchpad.net/~compiz-team/compiz/compiz.fix_1080989/+merge/135065
> Your team Compiz Maintainers is subscribed to branch lp:compiz.
>

Revision history for this message
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

As for some other things:

Copyrights: no significant change, just extracting a header. Not worth it
IMO.

Test name: any ideas?

Separate bug: I think this is separate from the segfaults. The segfaults
are an issue with the gsettings back end, this one is about the global
profile selection being broken.
On 20/11/2012 5:34 PM, "Daniel van Vugt" <email address hidden>
wrote:

> Review: Needs Fixing
>
> I can't reproduce anything like bug 1080989 to verify. But I can see that
> this seems to fix bug 1070817. Can we make it bug 1070817 instead or are
> they separate?
>
> Also, the copyright header on new files should be one of your own :)
> --
>
> https://code.launchpad.net/~compiz-team/compiz/compiz.fix_1080989/+merge/135065
> Your team Compiz Maintainers is subscribed to branch lp:compiz.
>

Revision history for this message
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

I've linked the bugs you suggested and simplified the test names. Copyright in the header is unchanged, as its effectively not my code.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

OK, all good. Maybe if you're reorganizing other peoples' code it would be best to add your own copyright below the existing ones. Because clearly the structure of the code is no longer the work of the original author(s).

Also I personally have a pet hate of:
    if (strlen (profile))
because it's just an inefficient way of writing:
    if (profile[0])
But that's just me.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added file 'compizconfig/libcompizconfig/src/ccs-config-private.h'
--- compizconfig/libcompizconfig/src/ccs-config-private.h 1970-01-01 00:00:00 +0000
+++ compizconfig/libcompizconfig/src/ccs-config-private.h 2012-11-20 14:53:24 +0000
@@ -0,0 +1,32 @@
1/*
2 * Compiz configuration system library
3 *
4 * Copyright (C) 2007 Dennis Kasprzyk <onestone@opencompositing.org>
5 * Copyright (C) 2007 Danny Baumann <maniac@opencompositing.org>
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21#ifndef COMPIZCONFIG_CCS_CONFIG_PRIVATE_H
22#define COMPIZCONFIG_CCS_CONFIG_PRIVATE_H
23
24#include <ccs-defs.h>
25
26COMPIZCONFIG_BEGIN_DECLS
27
28char * getSectionName (void);
29
30COMPIZCONFIG_END_DECLS
31
32#endif
033
=== modified file 'compizconfig/libcompizconfig/src/config.c'
--- compizconfig/libcompizconfig/src/config.c 2012-05-21 09:36:37 +0000
+++ compizconfig/libcompizconfig/src/config.c 2012-11-20 14:53:24 +0000
@@ -26,6 +26,7 @@
26#include <string.h>26#include <string.h>
2727
28#include "ccs-private.h"28#include "ccs-private.h"
29#include "ccs-config-private.h"
2930
30#define SETTINGPATH "compiz-1/compizconfig"31#define SETTINGPATH "compiz-1/compizconfig"
3132
@@ -56,17 +57,24 @@
56 return NULL;57 return NULL;
57}58}
5859
59static char*60char *
60getSectionName (void)61getSectionName (void)
61{62{
62 char *profile;63 char *profile;
63 char *section;64 char *section;
6465
65 profile = getenv ("COMPIZ_CONFIG_PROFILE");66 profile = getenv ("COMPIZ_CONFIG_PROFILE");
66 if (profile && strlen (profile))67 if (profile)
67 {68 {
68 if (asprintf (&section, "general_%s", profile) == -1)69 if (strlen (profile))
69 section = NULL;70 {
71 if (asprintf (&section, "general_%s", profile) == -1)
72 section = NULL;
73 }
74 else
75 {
76 section = strdup ("general");
77 }
7078
71 return section;79 return section;
72 }80 }
7381
=== modified file 'compizconfig/libcompizconfig/tests/compizconfig_test_ccs_util.cpp'
--- compizconfig/libcompizconfig/tests/compizconfig_test_ccs_util.cpp 2012-10-03 09:00:57 +0000
+++ compizconfig/libcompizconfig/tests/compizconfig_test_ccs_util.cpp 2012-11-20 14:53:24 +0000
@@ -19,11 +19,18 @@
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */20 */
2121
22#include <iostream>
23
24#include <cstdlib>
25
22#include <gtest/gtest.h>26#include <gtest/gtest.h>
23#include <gtest_shared_characterwrapper.h>27#include <gtest_shared_characterwrapper.h>
2428
29#include <boost/noncopyable.hpp>
30
25#include <ccs.h>31#include <ccs.h>
26#include <ccs-private.h>32#include <ccs-private.h>
33#include <ccs-config-private.h>
27#include <ccs-modifier-list-inl.h>34#include <ccs-modifier-list-inl.h>
2835
29using ::testing::WithParamInterface;36using ::testing::WithParamInterface;
@@ -236,3 +243,133 @@
236243
237 EXPECT_EQ (expectedModifierMask, modifierMask);244 EXPECT_EQ (expectedModifierMask, modifierMask);
238}245}
246
247namespace
248{
249static const std::string emptyProfileName ("");
250static const std::string globalTestProfileName ("test");
251static const std::string globalGeneralProfileSection ("general");
252static const std::string globalGeneralProfileSectionUnderscore ("general_");
253static const std::string globalTestGeneralProfileSection (globalGeneralProfileSectionUnderscore + globalTestProfileName);
254static const std::string globalGNOMEProfileSection ("gnome_session");
255static const std::string globalKDE4ProfileSection ("kde4_session");
256static const std::string globalKDE3ProfileSection ("kde_session");
257static const std::string four ("4");
258static const std::string trueStr ("true");
259
260class TmpEnv :
261 boost::noncopyable
262{
263 public:
264
265 explicit TmpEnv (const char *env, const char *val) :
266 envRestore (env),
267 envRestoreVal (getenv (env))
268 {
269 if (!val)
270 unsetenv (env);
271 else
272 setenv (env, val, TRUE);
273 }
274
275 ~TmpEnv ()
276 {
277 if (envRestoreVal)
278 setenv (envRestore, envRestoreVal, TRUE);
279 else
280 unsetenv (envRestore);
281 }
282
283 private:
284
285 const char *envRestore;
286 const char *envRestoreVal;
287};
288
289const char * getConstCharFromCharacterWrapper (const CharacterWrapper &wrap)
290{
291 return wrap;
292}
293
294}
295
296std::ostream &
297operator<< (std::ostream &os, const CharacterWrapper &wrap)
298{
299 return os << getConstCharFromCharacterWrapper (wrap);
300}
301
302bool
303operator== (const std::string &str, const CharacterWrapper &wrap)
304{
305 return str == getConstCharFromCharacterWrapper (wrap);
306}
307
308class CCSUtilProfileSelection :
309 public ::testing::Test
310{
311 public:
312
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)
318 {
319 }
320
321 private:
322
323 TmpEnv ccsEnv;
324 TmpEnv gnomeEnv;
325 TmpEnv kde4Env;
326 TmpEnv kdeEnv;
327};
328
329TEST_F (CCSUtilProfileSelection, OverrideWithName)
330{
331 TmpEnv env ("COMPIZ_CONFIG_PROFILE", globalTestProfileName.c_str ());
332 CharacterWrapper sName (getSectionName ());
333
334 EXPECT_EQ (globalTestGeneralProfileSection, sName);
335}
336
337TEST_F (CCSUtilProfileSelection, OverrideWithNoName)
338{
339 TmpEnv env ("COMPIZ_CONFIG_PROFILE", emptyProfileName.c_str ());
340 CharacterWrapper sName (getSectionName ());
341
342 EXPECT_EQ (globalGeneralProfileSection, sName);
343}
344
345TEST_F (CCSUtilProfileSelection, NoOverrideInGNOME)
346{
347 TmpEnv env ("GNOME_DESKTOP_SESSION_ID", globalTestProfileName.c_str ());
348 CharacterWrapper sName (getSectionName ());
349
350 EXPECT_EQ (globalGNOMEProfileSection, sName);
351}
352
353TEST_F (CCSUtilProfileSelection, NoOverrideInKDE4)
354{
355 TmpEnv env ("KDE_SESSION_VERSION", four.c_str ());
356 CharacterWrapper sName (getSectionName ());
357
358 EXPECT_EQ (globalKDE4ProfileSection, sName);
359}
360
361TEST_F (CCSUtilProfileSelection, NoOverrideInKDE3)
362{
363 TmpEnv env ("KDE_FULL_SESSION", trueStr.c_str ());
364 CharacterWrapper sName (getSectionName ());
365
366 EXPECT_EQ (globalKDE3ProfileSection, sName);
367}
368
369TEST_F (CCSUtilProfileSelection, Fallback)
370{
371 CharacterWrapper sName (getSectionName ());
372
373 EXPECT_EQ (globalGeneralProfileSection, sName);
374}
375

Subscribers

People subscribed via source and target branches