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 * ());
176
// Utility class to help satisfy dependencies
177
class xdisplay : boost::noncopyable
181
xdisplay() : display(XOpenDisplay (0)) {}
182
~xdisplay() { XCloseDisplay(display); }
184
Display* get() const { return display; }
176
MOCK_CONST_METHOD0(createFailed, bool ());
187
179
} // (anon) namespace
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);
297
294
PluginFilesystem const* PluginFilesystem::instance = 0;
299
296
} // (abstract) namespace
302
TEST(PrivateScreenTest, create_and_destroy)
304
using namespace testing;
306
MockCompScreen comp_screen;
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));
312
// The PrivateScreen ctor indirectly calls screen->dpy().
313
// We should kill this dependency
315
EXPECT_CALL(comp_screen, dpy()).WillRepeatedly(Return(display.get()));
317
comp_screen.priv.reset(new PrivateScreen(&comp_screen));
320
TEST(PrivateScreenTest, calling_init)
322
using namespace testing;
324
MockCompScreen comp_screen;
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));
330
// The PrivateScreen ctor indirectly calls screen->dpy().
331
// We should kill this dependency
333
EXPECT_CALL(comp_screen, dpy()).WillRepeatedly(Return(display.get()));
335
comp_screen.priv.reset(new PrivateScreen(&comp_screen));
336
PrivateScreen& ps(*comp_screen.priv.get());
338
MockPluginFilesystem mockfs;
343
TEST(PrivateScreenTest, calling_updatePlugins_does_not_error)
345
using namespace testing;
347
MockCompScreen comp_screen;
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));
353
// The PrivateScreen ctor indirectly calls screen->dpy().
354
// We should kill this dependency
356
EXPECT_CALL(comp_screen, dpy()).WillRepeatedly(Return(display.get()));
358
PrivateScreen ps(&comp_screen);
298
namespace cps = compiz::private_screen;
300
TEST(privatescreen_PluginManagerTest, create_and_destroy)
302
using namespace testing;
304
MockCompScreen comp_screen;
306
cps::PluginManager ps;
309
TEST(privatescreen_PluginManagerTest, calling_updatePlugins_does_not_error)
311
using namespace testing;
313
MockCompScreen comp_screen;
315
cps::PluginManager ps;
360
317
// Stuff that has to be done before calling updatePlugins()
362
318
CompOption::Value::Vector values;
363
319
values.push_back ("core");
364
320
ps.plugin.set (CompOption::TypeString, values);
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();
373
TEST(PrivateScreenTest, calling_updatePlugins_after_setting_initialPlugins)
329
TEST(privatescreen_PluginManagerTest, calling_updatePlugins_after_setting_initialPlugins)
375
331
using namespace testing;
377
333
MockCompScreen comp_screen;
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));
383
// The PrivateScreen ctor indirectly calls screen->dpy().
384
// We should kill this dependency
386
EXPECT_CALL(comp_screen, dpy()).WillRepeatedly(Return(display.get()));
388
comp_screen.priv.reset(new PrivateScreen(&comp_screen));
389
PrivateScreen& ps(*comp_screen.priv.get());
335
cps::PluginManager ps;
391
337
// Stuff that has to be done before calling updatePlugins()
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));
369
TEST(privatescreen_EventManagerTest, create_and_destroy)
371
using namespace testing;
373
MockCompScreen comp_screen;
375
cps::EventManager em(0);
378
TEST(privatescreen_EventManagerTest, init)
380
using namespace testing;
382
MockCompScreen comp_screen;
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));
388
// The PrivateScreen ctor indirectly calls screen->dpy().
389
// We should kill this dependency
390
EXPECT_CALL(comp_screen, dpy()).WillRepeatedly(Return((Display*)(0)));
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());