~ubuntu-branches/ubuntu/precise/compiz/precise

« back to all changes in this revision

Viewing changes to src/privatescreen/tests/test-privatescreen.cpp

  • Committer: Package Import Robot
  • Author(s): Didier Roche, Łukasz 'sil2100' Zemczak, Didier Roche
  • Date: 2012-03-12 10:22:10 UTC
  • mfrom: (0.168.15)
  • Revision ID: package-import@ubuntu.com-20120312102210-e248pzbccr7r2tdq
Tags: 1:0.9.7.0+bzr3035-0ubuntu1
[ Łukasz 'sil2100' Zemczak ]
* New upstream snapshot:
  - Fix gtk-window-decorator crash upon demaximizing a window (LP: #930071)
  - Fix core keybindings (LP: #930412)
  - Fixes compiz crash with SIGSEGV on shutdown (LP: #931283)
  - Plugins can't tell the difference between a key-tap and modifier
    key-release (LP: #925293)
  - compiz-core r3001 (and 3002) ftbfs (LP: #933226)
  - Semi-maximized windows have no shadow or frame (LP: #924736)
  - Untranslated strings in gtk-window-decorator (LP: #780505)
  - Initialize the _NET_WM_STATE_FOCUSED (LP: #932087)
  - [regression] Customized shortcuts don't work (LP: #931927)
  - Window stacking problem (LP: #936675)
  - Quickly demaximized windows can receive maximized window decorations if 
    they were initially maximized (LP: #936778)
  - Maximized windows do not get shadows at all (LP: #936774)
  - [regression] Launcher, top panel and keyboard un-responsive after using 
    any Super-x shortcut (LP: #934058)
  - No draggable border if mutter isn't installed (LP: #936781)
  - Fix compiz crash with SIGSEGV in XDefineCursor() (LP: #936487)
  - Fixes memory leak at DecorWindow::updateSwitcher() (LP: #940115)
  - Unresolved symbols in plugins cause compiz to exit (LP: #938478)
  - Fix compiz spending about 51% of its CPU time in CompRegion 
    construction/destruction (LP: #940139)
  - Fix Conditional jump or move depends on uninitialised value(s) in 
    decor_match_pixmap (LP: #940066)
  - Fix 'show desktop' behaviour (LP: #871801)
  - Tweak algorithm used to cast shadows on maximized windows (LP: #936784)
  - "Svg" and "Png" should be "SVG and "PNG" (LP: #942890)
  - Fix invalid memory usage after free() in DecorWindow (LP: #943116)
  - Fix alt + F10 (LP: #943223)
* Removed cherry-picked patches
* debian/patches/fix_944631.patch:
  - Always replay the keyboard if something was grabbed and didn't trigger 
    an action and don't trigger actions which aren't added accidentally 
    (LP: #943612) (LP: #944631)
* debian/patches/fix_923683.patch:
  - Backports a patch which prevents the shift race condition

[ Didier Roche ]
* debian/patches/fix_alt_pressing.patch:
  - Patch from ddv to fix all the regressions with the alt key fix and other
    (LP: #943851, #945373)
  - Fix Quicklist are not showing if right-clicking a launcher icon in Expo
    mode if triggered by Super + S (LP: #944979)
* debian/patches/fix_806255.patch:
  - Unity/compiz intercepts keystrokes from grabbed windows (LP: #806255)
* debian/patches/fix_943194.patch:
  - second part for the alt key fix (LP: #943194)
* debian/patches/additional_alt_tapping_fix.patch:
  - again another alt tapping related fix for some regressions from the
    previous branch. Taken from "tapping-panacea" upstream branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
#include <gtest/gtest.h>
9
9
#include <gmock/gmock.h>
10
10
 
 
11
#include <stdlib.h>
11
12
 
12
13
namespace {
13
14
 
16
17
public:
17
18
    MockCompScreen()
18
19
    {
19
 
        // The PrivateScreen ctor uses screen->... (indirectly)
 
20
        // The PluginManager ctor uses screen->... (indirectly via CoreOptions)
20
21
        // We should kill this dependency
21
22
        screen = this;
22
23
    }
23
24
 
24
25
    ~MockCompScreen()
25
26
    {
26
 
        // Because of another indirect use of screen in PrivateScreen dtor
 
27
        // Because of another indirect use of screen in PluginManager dtor
27
28
        // via option.cpp:finiOptionValue()
28
29
        screen = 0;
29
30
    }
166
167
    MOCK_METHOD0(syncEvent, int ());
167
168
    MOCK_METHOD0(autoRaiseWindow, Window  ());
168
169
    MOCK_METHOD0(processEvents, void ());
 
170
    MOCK_METHOD1(alwaysHandleEvent, void (XEvent *event));
169
171
    MOCK_METHOD0(displayString, const char * ());
170
172
    MOCK_METHOD0(getCurrentOutputExtents, CompRect ());
171
173
    MOCK_METHOD0(normalCursor, Cursor ());
172
174
    MOCK_METHOD0(grabbed, bool ());
173
175
    MOCK_METHOD0(snDisplay, SnDisplay * ());
174
 
};
175
 
 
176
 
// Utility class to help satisfy dependencies
177
 
class xdisplay : boost::noncopyable
178
 
{
179
 
    Display* display;
180
 
public:
181
 
    xdisplay() : display(XOpenDisplay (0)) {}
182
 
    ~xdisplay() { XCloseDisplay(display); }
183
 
 
184
 
    Display* get() const { return display; }
 
176
    MOCK_CONST_METHOD0(createFailed, bool ());
185
177
};
186
178
 
187
179
} // (anon) namespace
294
286
        instance = this;
295
287
}
296
288
 
 
289
// tell GLib not to use the slice-allocator implementation
 
290
// and avoid spurious valgrind reporting
 
291
void glib_nice_for_valgrind() { setenv("G_SLICE", "always-malloc", true); }
 
292
int const init = (glib_nice_for_valgrind(), 0);
 
293
 
297
294
PluginFilesystem const* PluginFilesystem::instance = 0;
298
295
 
299
296
} // (abstract) namespace
300
297
 
301
 
 
302
 
TEST(PrivateScreenTest, create_and_destroy)
303
 
{
304
 
    using namespace testing;
305
 
 
306
 
    MockCompScreen comp_screen;
307
 
 
308
 
    EXPECT_CALL(comp_screen, addAction(_)).WillRepeatedly(Return(false));
309
 
    EXPECT_CALL(comp_screen, removeAction(_)).WillRepeatedly(Return());
310
 
    EXPECT_CALL(comp_screen, _matchInitExp(StrEq("any"))).WillRepeatedly(Return((CompMatch::Expression*)0));
311
 
 
312
 
    // The PrivateScreen ctor indirectly calls screen->dpy().
313
 
    // We should kill this dependency
314
 
    xdisplay display;
315
 
    EXPECT_CALL(comp_screen, dpy()).WillRepeatedly(Return(display.get()));
316
 
 
317
 
    comp_screen.priv.reset(new PrivateScreen(&comp_screen));
318
 
}
319
 
 
320
 
TEST(PrivateScreenTest, calling_init)
321
 
{
322
 
    using namespace testing;
323
 
 
324
 
    MockCompScreen comp_screen;
325
 
 
326
 
    EXPECT_CALL(comp_screen, addAction(_)).WillRepeatedly(Return(false));
327
 
    EXPECT_CALL(comp_screen, removeAction(_)).WillRepeatedly(Return());
328
 
    EXPECT_CALL(comp_screen, _matchInitExp(StrEq("any"))).WillRepeatedly(Return((CompMatch::Expression*)0));
329
 
 
330
 
    // The PrivateScreen ctor indirectly calls screen->dpy().
331
 
    // We should kill this dependency
332
 
    xdisplay display;
333
 
    EXPECT_CALL(comp_screen, dpy()).WillRepeatedly(Return(display.get()));
334
 
 
335
 
    comp_screen.priv.reset(new PrivateScreen(&comp_screen));
336
 
    PrivateScreen& ps(*comp_screen.priv.get());
337
 
 
338
 
    MockPluginFilesystem mockfs;
339
 
 
340
 
    ps.init(0);
341
 
}
342
 
 
343
 
TEST(PrivateScreenTest, calling_updatePlugins_does_not_error)
344
 
{
345
 
    using namespace testing;
346
 
 
347
 
    MockCompScreen comp_screen;
348
 
 
349
 
    EXPECT_CALL(comp_screen, addAction(_)).WillRepeatedly(Return(false));
350
 
    EXPECT_CALL(comp_screen, removeAction(_)).WillRepeatedly(Return());
351
 
    EXPECT_CALL(comp_screen, _matchInitExp(StrEq("any"))).WillRepeatedly(Return((CompMatch::Expression*)0));
352
 
 
353
 
    // The PrivateScreen ctor indirectly calls screen->dpy().
354
 
    // We should kill this dependency
355
 
    xdisplay display;
356
 
    EXPECT_CALL(comp_screen, dpy()).WillRepeatedly(Return(display.get()));
357
 
 
358
 
    PrivateScreen ps(&comp_screen);
 
298
namespace cps = compiz::private_screen;
 
299
 
 
300
TEST(privatescreen_PluginManagerTest, create_and_destroy)
 
301
{
 
302
    using namespace testing;
 
303
 
 
304
    MockCompScreen comp_screen;
 
305
 
 
306
    cps::PluginManager ps;
 
307
}
 
308
 
 
309
TEST(privatescreen_PluginManagerTest, calling_updatePlugins_does_not_error)
 
310
{
 
311
    using namespace testing;
 
312
 
 
313
    MockCompScreen comp_screen;
 
314
 
 
315
    cps::PluginManager ps;
359
316
 
360
317
    // Stuff that has to be done before calling updatePlugins()
361
 
    ps.init(0);
362
318
    CompOption::Value::Vector values;
363
319
    values.push_back ("core");
364
320
    ps.plugin.set (CompOption::TypeString, values);
366
322
 
367
323
    // Now we can call updatePlugins() without a segfault.  Hoorah!
368
324
    EXPECT_CALL(comp_screen, _setOptionForPlugin(StrEq("core"), StrEq("active_plugins"), _)).
369
 
            WillOnce(Return(false));
 
325
        WillOnce(Return(false));
370
326
    ps.updatePlugins();
371
327
}
372
328
 
373
 
TEST(PrivateScreenTest, calling_updatePlugins_after_setting_initialPlugins)
 
329
TEST(privatescreen_PluginManagerTest, calling_updatePlugins_after_setting_initialPlugins)
374
330
{
375
331
    using namespace testing;
376
332
 
377
333
    MockCompScreen comp_screen;
378
334
 
379
 
    EXPECT_CALL(comp_screen, addAction(_)).WillRepeatedly(Return(false));
380
 
    EXPECT_CALL(comp_screen, removeAction(_)).WillRepeatedly(Return());
381
 
    EXPECT_CALL(comp_screen, _matchInitExp(StrEq("any"))).WillRepeatedly(Return((CompMatch::Expression*)0));
382
 
 
383
 
    // The PrivateScreen ctor indirectly calls screen->dpy().
384
 
    // We should kill this dependency
385
 
    xdisplay display;
386
 
    EXPECT_CALL(comp_screen, dpy()).WillRepeatedly(Return(display.get()));
387
 
 
388
 
    comp_screen.priv.reset(new PrivateScreen(&comp_screen));
389
 
    PrivateScreen& ps(*comp_screen.priv.get());
 
335
    cps::PluginManager ps;
390
336
 
391
337
    // Stuff that has to be done before calling updatePlugins()
392
 
    ps.init(0);
393
338
    CompOption::Value::Vector values;
394
339
    values.push_back ("core");
395
340
    ps.plugin.set (CompOption::TypeString, values);
420
365
    EXPECT_CALL(comp_screen, _finiPluginForScreen(Ne((void*)0))).Times(2);
421
366
    for (CompPlugin* p; (p = CompPlugin::pop ()) != 0; CompPlugin::unload (p));
422
367
}
 
368
 
 
369
TEST(privatescreen_EventManagerTest, create_and_destroy)
 
370
{
 
371
    using namespace testing;
 
372
 
 
373
    MockCompScreen comp_screen;
 
374
 
 
375
    cps::EventManager em(0);
 
376
}
 
377
 
 
378
TEST(privatescreen_EventManagerTest, init)
 
379
{
 
380
    using namespace testing;
 
381
 
 
382
    MockCompScreen comp_screen;
 
383
 
 
384
    EXPECT_CALL(comp_screen, addAction(_)).WillRepeatedly(Return(false));
 
385
    EXPECT_CALL(comp_screen, removeAction(_)).WillRepeatedly(Return());
 
386
    EXPECT_CALL(comp_screen, _matchInitExp(StrEq("any"))).WillRepeatedly(Return((CompMatch::Expression*)0));
 
387
 
 
388
    // The PrivateScreen ctor indirectly calls screen->dpy().
 
389
    // We should kill this dependency
 
390
    EXPECT_CALL(comp_screen, dpy()).WillRepeatedly(Return((Display*)(0)));
 
391
 
 
392
    // TODO - we can't yet detach the EventManager from ::screen->priv
 
393
    // vis: replace next two lines with cps::EventManager em(&comp_screen);
 
394
    comp_screen.priv.reset(new PrivateScreen(&comp_screen));
 
395
    cps::EventManager& em(*comp_screen.priv.get());
 
396
 
 
397
    em.init(0);
 
398
}