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
1=== added file 'compizconfig/libcompizconfig/src/ccs-config-private.h'
2--- compizconfig/libcompizconfig/src/ccs-config-private.h 1970-01-01 00:00:00 +0000
3+++ compizconfig/libcompizconfig/src/ccs-config-private.h 2012-11-20 14:53:24 +0000
4@@ -0,0 +1,32 @@
5+/*
6+ * Compiz configuration system library
7+ *
8+ * Copyright (C) 2007 Dennis Kasprzyk <onestone@opencompositing.org>
9+ * Copyright (C) 2007 Danny Baumann <maniac@opencompositing.org>
10+ *
11+ * This library is free software; you can redistribute it and/or
12+ * modify it under the terms of the GNU Lesser General Public
13+ * License as published by the Free Software Foundation; either
14+ * version 2.1 of the License, or (at your option) any later version.
15+
16+ * This library is distributed in the hope that it will be useful,
17+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
18+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19+ * Lesser General Public License for more details.
20+
21+ * You should have received a copy of the GNU Lesser General Public
22+ * License along with this library; if not, write to the Free Software
23+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24+ */
25+#ifndef COMPIZCONFIG_CCS_CONFIG_PRIVATE_H
26+#define COMPIZCONFIG_CCS_CONFIG_PRIVATE_H
27+
28+#include <ccs-defs.h>
29+
30+COMPIZCONFIG_BEGIN_DECLS
31+
32+char * getSectionName (void);
33+
34+COMPIZCONFIG_END_DECLS
35+
36+#endif
37
38=== modified file 'compizconfig/libcompizconfig/src/config.c'
39--- compizconfig/libcompizconfig/src/config.c 2012-05-21 09:36:37 +0000
40+++ compizconfig/libcompizconfig/src/config.c 2012-11-20 14:53:24 +0000
41@@ -26,6 +26,7 @@
42 #include <string.h>
43
44 #include "ccs-private.h"
45+#include "ccs-config-private.h"
46
47 #define SETTINGPATH "compiz-1/compizconfig"
48
49@@ -56,17 +57,24 @@
50 return NULL;
51 }
52
53-static char*
54+char *
55 getSectionName (void)
56 {
57 char *profile;
58 char *section;
59
60 profile = getenv ("COMPIZ_CONFIG_PROFILE");
61- if (profile && strlen (profile))
62+ if (profile)
63 {
64- if (asprintf (&section, "general_%s", profile) == -1)
65- section = NULL;
66+ if (strlen (profile))
67+ {
68+ if (asprintf (&section, "general_%s", profile) == -1)
69+ section = NULL;
70+ }
71+ else
72+ {
73+ section = strdup ("general");
74+ }
75
76 return section;
77 }
78
79=== modified file 'compizconfig/libcompizconfig/tests/compizconfig_test_ccs_util.cpp'
80--- compizconfig/libcompizconfig/tests/compizconfig_test_ccs_util.cpp 2012-10-03 09:00:57 +0000
81+++ compizconfig/libcompizconfig/tests/compizconfig_test_ccs_util.cpp 2012-11-20 14:53:24 +0000
82@@ -19,11 +19,18 @@
83 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
84 */
85
86+#include <iostream>
87+
88+#include <cstdlib>
89+
90 #include <gtest/gtest.h>
91 #include <gtest_shared_characterwrapper.h>
92
93+#include <boost/noncopyable.hpp>
94+
95 #include <ccs.h>
96 #include <ccs-private.h>
97+#include <ccs-config-private.h>
98 #include <ccs-modifier-list-inl.h>
99
100 using ::testing::WithParamInterface;
101@@ -236,3 +243,133 @@
102
103 EXPECT_EQ (expectedModifierMask, modifierMask);
104 }
105+
106+namespace
107+{
108+static const std::string emptyProfileName ("");
109+static const std::string globalTestProfileName ("test");
110+static const std::string globalGeneralProfileSection ("general");
111+static const std::string globalGeneralProfileSectionUnderscore ("general_");
112+static const std::string globalTestGeneralProfileSection (globalGeneralProfileSectionUnderscore + globalTestProfileName);
113+static const std::string globalGNOMEProfileSection ("gnome_session");
114+static const std::string globalKDE4ProfileSection ("kde4_session");
115+static const std::string globalKDE3ProfileSection ("kde_session");
116+static const std::string four ("4");
117+static const std::string trueStr ("true");
118+
119+class TmpEnv :
120+ boost::noncopyable
121+{
122+ public:
123+
124+ explicit TmpEnv (const char *env, const char *val) :
125+ envRestore (env),
126+ envRestoreVal (getenv (env))
127+ {
128+ if (!val)
129+ unsetenv (env);
130+ else
131+ setenv (env, val, TRUE);
132+ }
133+
134+ ~TmpEnv ()
135+ {
136+ if (envRestoreVal)
137+ setenv (envRestore, envRestoreVal, TRUE);
138+ else
139+ unsetenv (envRestore);
140+ }
141+
142+ private:
143+
144+ const char *envRestore;
145+ const char *envRestoreVal;
146+};
147+
148+const char * getConstCharFromCharacterWrapper (const CharacterWrapper &wrap)
149+{
150+ return wrap;
151+}
152+
153+}
154+
155+std::ostream &
156+operator<< (std::ostream &os, const CharacterWrapper &wrap)
157+{
158+ return os << getConstCharFromCharacterWrapper (wrap);
159+}
160+
161+bool
162+operator== (const std::string &str, const CharacterWrapper &wrap)
163+{
164+ return str == getConstCharFromCharacterWrapper (wrap);
165+}
166+
167+class CCSUtilProfileSelection :
168+ public ::testing::Test
169+{
170+ public:
171+
172+ CCSUtilProfileSelection () :
173+ ccsEnv ("COMPIZ_CONFIG_PROFILE", NULL),
174+ gnomeEnv ("GNOME_DESKTOP_SESSION_ID", NULL),
175+ kde4Env ("KDE_SESSION_VERSION", NULL),
176+ kdeEnv ("KDE_FULL_SESSION", NULL)
177+ {
178+ }
179+
180+ private:
181+
182+ TmpEnv ccsEnv;
183+ TmpEnv gnomeEnv;
184+ TmpEnv kde4Env;
185+ TmpEnv kdeEnv;
186+};
187+
188+TEST_F (CCSUtilProfileSelection, OverrideWithName)
189+{
190+ TmpEnv env ("COMPIZ_CONFIG_PROFILE", globalTestProfileName.c_str ());
191+ CharacterWrapper sName (getSectionName ());
192+
193+ EXPECT_EQ (globalTestGeneralProfileSection, sName);
194+}
195+
196+TEST_F (CCSUtilProfileSelection, OverrideWithNoName)
197+{
198+ TmpEnv env ("COMPIZ_CONFIG_PROFILE", emptyProfileName.c_str ());
199+ CharacterWrapper sName (getSectionName ());
200+
201+ EXPECT_EQ (globalGeneralProfileSection, sName);
202+}
203+
204+TEST_F (CCSUtilProfileSelection, NoOverrideInGNOME)
205+{
206+ TmpEnv env ("GNOME_DESKTOP_SESSION_ID", globalTestProfileName.c_str ());
207+ CharacterWrapper sName (getSectionName ());
208+
209+ EXPECT_EQ (globalGNOMEProfileSection, sName);
210+}
211+
212+TEST_F (CCSUtilProfileSelection, NoOverrideInKDE4)
213+{
214+ TmpEnv env ("KDE_SESSION_VERSION", four.c_str ());
215+ CharacterWrapper sName (getSectionName ());
216+
217+ EXPECT_EQ (globalKDE4ProfileSection, sName);
218+}
219+
220+TEST_F (CCSUtilProfileSelection, NoOverrideInKDE3)
221+{
222+ TmpEnv env ("KDE_FULL_SESSION", trueStr.c_str ());
223+ CharacterWrapper sName (getSectionName ());
224+
225+ EXPECT_EQ (globalKDE3ProfileSection, sName);
226+}
227+
228+TEST_F (CCSUtilProfileSelection, Fallback)
229+{
230+ CharacterWrapper sName (getSectionName ());
231+
232+ EXPECT_EQ (globalGeneralProfileSection, sName);
233+}
234+

Subscribers

People subscribed via source and target branches