Merge lp:~compiz-team/compiz/compiz.gsettings_conformance_test into lp:compiz/0.9.8

Proposed by Sam Spilsbury
Status: Superseded
Proposed branch: lp:~compiz-team/compiz/compiz.gsettings_conformance_test
Merge into: lp:compiz/0.9.8
Prerequisite: lp:~compiz-team/compiz/compiz.split_gsettings_rw_funcs
Diff against target: 2746 lines (+1354/-274)
19 files modified
compizconfig/gconf/src/gconf.c (+20/-11)
compizconfig/gsettings/gsettings_backend_shared/gsettings_util.c (+140/-10)
compizconfig/gsettings/gsettings_backend_shared/gsettings_util.h (+63/-3)
compizconfig/gsettings/src/gconf-integration.c (+5/-3)
compizconfig/gsettings/src/gsettings.c (+93/-113)
compizconfig/gsettings/src/gsettings.h (+6/-4)
compizconfig/gsettings/tests/CMakeLists.txt (+32/-2)
compizconfig/gsettings/tests/backend-conformance-config.h.in (+2/-0)
compizconfig/gsettings/tests/org.compiz.mock.gschema.xml (+50/-0)
compizconfig/gsettings/tests/test_gsettings_conformance.cpp (+431/-0)
compizconfig/gsettings/tests/test_gsettings_tests.cpp (+1/-1)
compizconfig/libcompizconfig/backend/src/ini.c (+11/-0)
compizconfig/libcompizconfig/include/ccs-backend.h (+12/-1)
compizconfig/libcompizconfig/include/ccs.h (+4/-0)
compizconfig/libcompizconfig/src/main.c (+31/-8)
compizconfig/libcompizconfig/tests/compizconfig_test_ccs_mock_backend_conformance.cpp (+91/-8)
compizconfig/mocks/libcompizconfig/compizconfig_ccs_backend_mock.cpp (+1/-0)
compizconfig/mocks/libcompizconfig/compizconfig_ccs_backend_mock.h (+7/-0)
compizconfig/tests/compizconfig_backend_concept_test.h (+354/-110)
To merge this branch: bzr merge lp:~compiz-team/compiz/compiz.gsettings_conformance_test
Reviewer Review Type Date Requested Status
Compiz Maintainers Pending
Review via email: mp+114581@code.launchpad.net

This proposal has been superseded by a proposal from 2012-07-21.

Description of the change

Instantiate the GSettings backend in a test harness and run the conformance tests on it.

This is not actually needing review, I've just got it marked as Needs Review so that the CI bot will run tests on it.

To post a comment you must log in.
3338. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3339. By Sam Spilsbury

Merge

3340. By Sam Spilsbury

Correclty overload functions, remove other merge markers

3341. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3342. By Sam Spilsbury

Attach to the correct test fixture

3343. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3344. By Sam Spilsbury

Set appropriate expectaitons for gsettings backend conformance

3345. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3346. By Sam Spilsbury

Make the tests not crash

3347. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3348. By Sam Spilsbury

Make the write tests pass with a little less noise

3349. By Sam Spilsbury

Add integer expectations

3350. By Sam Spilsbury

Change mock settings so that they are always different from the
settings we change the values to in the tests

3351. By Sam Spilsbury

Provide CCSBackend to callers of translateKeyForGSettings so that we
can get the backend when we are going to register the callback

3352. By Sam Spilsbury

Hide signal connection behind interface

3353. By Sam Spilsbury

Neutralize the signal connection

3354. By Sam Spilsbury

Reduce the amount of noise when calling the write functions

3355. By Sam Spilsbury

Added float writing and reading funcs

3356. By Sam Spilsbury

Fill in the other read and write constructs, only some of the tests pass

3357. By Sam Spilsbury

Fix Bool/gboolean difference for read and write expecations

3358. By Sam Spilsbury

Fix string and match write tests, match is still being wonky...

3359. By Sam Spilsbury

Use the same GSettings object in the tests and in the backend and also
fix the color tests failing because of the lossy string conversion (simulate
this behaviour in the tests too and add a note saying that we expect it).

3360. By Sam Spilsbury

Fix key and button tests + printers

3361. By Sam Spilsbury

Fix missing break causing a test to fail

3362. By Sam Spilsbury

Fix broken ReadBellAtKey

3363. By Sam Spilsbury

Fix failing mock color test, we should simulate the toString behaviour
there too

3364. By Sam Spilsbury

Whitespace

3365. By Sam Spilsbury

We need to copy the lists and instantiate the lists a bit later
so that we don't get segfault due to a double free

3366. By Sam Spilsbury

Fix uninitialized read

3367. By Sam Spilsbury

Remove useless comment

3368. By Sam Spilsbury

Keep the setting object around for every instance of the value object.

3369. By Sam Spilsbury

Fix some spurious gmock warnings

3370. By Sam Spilsbury

Fix typo in test annotation

3371. By Sam Spilsbury

Fix unsafe array code fixing test CCSGSettingsBackendConcept/CCSBackendConformanceTestReadWrite

3372. By Sam Spilsbury

Fix bool comparison in ccsCompareLists when using multiple definitions
of TRUE and FALSE (it happens ...)

3373. By Sam Spilsbury

Added some notes as to remaining work

3374. By Sam Spilsbury

Store the initial color value list as lossy

3375. By Sam Spilsbury

Just calloc the array instead of memsetting every element and fix
color read in lists only reading into the first color

3376. By Sam Spilsbury

Remove lossy emulation, its no longer necessary now that we store
the initial values in a lossy format

3377. By Sam Spilsbury

Remove redundant comment

3378. By Sam Spilsbury

Provide the setting list type in ReadListAtKey. Make the list read tests pass

3379. By Sam Spilsbury

Fix typo in CCSGSettingsTestIndependent.TestReadVariantIsValidTypeGood

3380. By Sam Spilsbury

Ensure that variants are written to keys, now GSETTINGS_BACKEND=memory
works correctly

3381. By Sam Spilsbury

Added an updateSetting method to the backend interface, not actually used
anywhere yet

3382. By Sam Spilsbury

Added stub updateSetting definitions to the backend

3383. By Sam Spilsbury

Ini backend doesn't really have a concept of updating single settings,
but add a sensible definition in case someone wants to do it anyways

3384. By Sam Spilsbury

Added a sensible definition of updateSetting

3385. By Sam Spilsbury

Added a sensible definition of updateSetting for gsettings

3386. By Sam Spilsbury

Added test TestUpdateMockedValue

3387. By Sam Spilsbury

Added PostUpdate and PreUpdate hooks into the test fixture so now
MockCCSBackendConcept/CCSBackendConformanceTestReadWrite.TestUpdateMockedValue/*
will pass

3388. By Sam Spilsbury

Store path as a const char

3389. By Sam Spilsbury

Refactor out findSettingAndPluginToUpdateFromPath

3390. By Sam Spilsbury

Move it to gsettings_util

3391. By Sam Spilsbury

Refactor updateSettingWithGSettingsKeyName

3392. By Sam Spilsbury

Move updateSettingWithGSettingsKeyName into the util library

3393. By Sam Spilsbury

Added TestUpdateKeyedValue - all failing

3394. By Sam Spilsbury

Make the mock UpdateSettingAtKey tests pass

3395. By Sam Spilsbury

Make TestUpdateKeyedValu* pass on GSettings

3396. By Sam Spilsbury

Remove useless comment and unset evn

3397. By Sam Spilsbury

Always assume that lists are copied - fix list leak (and use smart
pointers more effectively)

3398. By Sam Spilsbury

Fix leaked path in CCSGSettingsBackendEnv::SetUp

3399. By Sam Spilsbury

Fix memory leak in readListValue in gsettings.c - we must always
provide a valid CCSSetting object otherwise ccsFreeSettingValue will not
actually free the setting value

3400. By Sam Spilsbury

Fix various memory leaks due to not unreffing some variants

3401. By Sam Spilsbury

Added debugging message

3402. By Sam Spilsbury

Put the expectation in the right place

3403. By Sam Spilsbury

Indirect the gconf client registration

3404. By Sam Spilsbury

Neuter gconf client connection

3405. By Sam Spilsbury

Lazy-register the gconf client

3406. By Sam Spilsbury

file (INSTALL ...) will respect DESTDIR by default, so no need to include
it again.

3407. By Sam Spilsbury

Fix some crashes in debian chroots

3408. By Sam Spilsbury

Make the profile general for tests

3409. By Sam Spilsbury

Added testing config backend

3410. By Sam Spilsbury

Merge lp:compiz

3411. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3412. By Sam Spilsbury

Merge

3413. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3414. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3415. By Sam Spilsbury

Merge

3416. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3417. By Sam Spilsbury

Merge

3418. By Sam Spilsbury

Added a quick TODO about the usage of sys.path

3419. By Sam Spilsbury

Just override sys.path[0] for now, need to prepend

3420. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3421. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3422. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3423. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3424. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3425. By Sam Spilsbury

Merge

3426. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3427. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3428. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3429. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3430. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3431. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3432. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3433. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3434. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3435. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3436. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3437. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3438. By Sam Spilsbury

Merge from previous. All the GSettings backend tests fail but that's fine

3439. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3440. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3441. By Sam Spilsbury

Fix crashing GSettings tests

3442. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3443. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3444. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3445. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3446. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3447. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3448. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3449. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3450. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3451. By Sam Spilsbury

Merge

3452. By Sam Spilsbury

Nuke unused function in header file

3453. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3454. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3455. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3456. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3457. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3458. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3459. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3460. By Sam Spilsbury

Merge

3461. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3462. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3463. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3464. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3465. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3466. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3467. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3468. By Sam Spilsbury

Moved CharacterWrapper definition into tests/shared/gtest_shared_characterwrapper.h

3469. By Sam Spilsbury

Merge

3470. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3471. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3472. By Sam Spilsbury

Merge

3473. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3474. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3475. By Sam Spilsbury

Fix merge marker

3476. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3477. By Sam Spilsbury

Add match-list-setting to the mock schema

3478. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3479. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3480. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3481. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3482. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3483. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3484. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3485. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3486. By Sam Spilsbury

Enable info tests for gsettigs

3487. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3488. By Sam Spilsbury

Use the much more sensible, law of demeter friendly version

3489. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3490. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3491. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3492. By Sam Spilsbury

Added expectation stubs and fix crash

3493. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3494. By Sam Spilsbury

Instantiate the tests and set the right expectations

3495. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3496. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3497. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3498. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3499. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3500. By Sam Spilsbury

Pass the object allocator too

3501. By Sam Spilsbury

First steps to getting the wrapper under test

3502. By Sam Spilsbury

Merge

3503. By Sam Spilsbury

Merge

3504. By Sam Spilsbury

Backend conformance config really belongs in gsettings

3505. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3506. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3507. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3508. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3509. By Sam Spilsbury

Update for API changes

3510. By Sam Spilsbury

Merge and remove redundant code

3511. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3512. By Sam Spilsbury

Test fixture for CCSGSettingsTestFindSettingAndPluginToUpdateFromPath

3513. By Sam Spilsbury

Comprehensive test coverage for FindSettingAndPluginToUpdateFromPath
and some cleanup, fix leaks etc

3514. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3515. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3516. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3517. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3518. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3519. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3520. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3521. By Sam Spilsbury

Added stubs for tests, fixed double unrefs due to GSettings' really
annoying stealing behaviour

3522. By Sam Spilsbury

Instantiate the CCSBackendConformanceTestProfileHandling suite for
the GSettings backend conformance test

3523. By Sam Spilsbury

Fix more double unref

3524. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3525. By Sam Spilsbury

Added AddProfile stub

3526. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3527. By Sam Spilsbury

Add default and current profiles correctly

3528. By Sam Spilsbury

Handle default and current profile cases in the tests a little better

3529. By Sam Spilsbury

Merge

3530. By Sam Spilsbury

Merge

3531. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3532. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3533. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3534. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3535. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3536. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3537. By Sam Spilsbury

Correct expectations

3538. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3539. By Sam Spilsbury

Merge

3540. By Sam Spilsbury

Fixed a set of memory leaks in the GSettings conformance tests - we must
be careful to unref the variants once they are read

3541. By Sam Spilsbury

Merge

3542. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3543. By Sam Spilsbury

Remove dupe file

3544. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3545. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3546. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

3547. By Sam Spilsbury

Merged compiz.split_gsettings_rw_funcs into compiz.gsettings_conformance_test.

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'compizconfig/gconf/src/gconf.c'
--- compizconfig/gconf/src/gconf.c 2012-07-21 20:44:19 +0000
+++ compizconfig/gconf/src/gconf.c 2012-07-21 20:44:20 +0000
@@ -436,6 +436,22 @@
436}436}
437437
438static void438static void
439updateSetting (CCSBackend *backend, CCSContext *context, CCSPlugin *plugin, CCSSetting *setting)
440{
441 int index;
442 readInit (backend, context);
443 if (!readOption (setting))
444 ccsResetToDefault (setting, TRUE);
445
446 if (ccsGetIntegrationEnabled (context) &&
447 isIntegratedOption (setting, &index))
448 {
449 writeInit (backend, context);
450 writeIntegratedOption (context, setting, index);
451 }
452}
453
454static void
439valueChanged (GConfClient *client,455valueChanged (GConfClient *client,
440 guint cnxn_id,456 guint cnxn_id,
441 GConfEntry *entry,457 GConfEntry *entry,
@@ -445,7 +461,6 @@
445 char *keyName = (char*) gconf_entry_get_key (entry);461 char *keyName = (char*) gconf_entry_get_key (entry);
446 char *pluginName;462 char *pluginName;
447 char *token;463 char *token;
448 int index;
449 unsigned int screenNum;464 unsigned int screenNum;
450 CCSPlugin *plugin;465 CCSPlugin *plugin;
451 CCSSetting *setting;466 CCSSetting *setting;
@@ -490,16 +505,9 @@
490 if (!setting)505 if (!setting)
491 return;506 return;
492507
493 readInit (NULL, context);508 /* Passing null here is not optimal, but we are not
494 if (!readOption (setting))509 * maintaining gconf actively here */
495 ccsResetToDefault (setting, TRUE);510 updateSetting (NULL, context, plugin, setting);
496
497 if (ccsGetIntegrationEnabled (context) &&
498 isIntegratedOption (setting, &index))
499 {
500 writeInit (NULL, context);
501 writeIntegratedOption (context, setting, index);
502 }
503}511}
504512
505static void513static void
@@ -2167,6 +2175,7 @@
2167 writeInit,2175 writeInit,
2168 writeSetting,2176 writeSetting,
2169 0,2177 0,
2178 updateSetting,
2170 getSettingIsIntegrated,2179 getSettingIsIntegrated,
2171 getSettingIsReadOnly,2180 getSettingIsReadOnly,
2172 getExistingProfiles,2181 getExistingProfiles,
21732182
=== modified file 'compizconfig/gsettings/gsettings_backend_shared/gsettings_util.c'
--- compizconfig/gsettings/gsettings_backend_shared/gsettings_util.c 2012-07-21 20:44:19 +0000
+++ compizconfig/gsettings/gsettings_backend_shared/gsettings_util.c 2012-07-21 20:44:20 +0000
@@ -4,6 +4,8 @@
4#include <stdio.h>4#include <stdio.h>
5#include "gsettings_shared.h"5#include "gsettings_shared.h"
66
7INTERFACE_TYPE (CCSGSettingsBackendInterface);
8
7GList *9GList *
8variantTypeToPossibleSettingType (const gchar *vt)10variantTypeToPossibleSettingType (const gchar *vt)
9{11{
@@ -328,6 +330,101 @@
328 return found;330 return found;
329}331}
330332
333Bool
334findSettingAndPluginToUpdateFromPath (GSettings *settings,
335 const char *path,
336 const gchar *keyName,
337 CCSContext *context,
338 CCSPlugin **plugin,
339 CCSSetting **setting,
340 char **uncleanKeyName)
341{
342 char *pluginName;
343 unsigned int screenNum;
344
345 if (!decomposeGSettingsPath (path, &pluginName, &screenNum))
346 return FALSE;
347
348 *plugin = ccsFindPlugin (context, pluginName);
349
350 if (*plugin)
351 {
352 *uncleanKeyName = translateKeyForCCS (keyName);
353
354 *setting = ccsFindSetting (*plugin, *uncleanKeyName);
355 if (!setting)
356 {
357 /* Couldn't find setting straight off the bat,
358 * try and find the best match */
359 GVariant *value = g_settings_get_value (settings, keyName);
360
361 if (value)
362 {
363 GList *possibleSettingTypes = variantTypeToPossibleSettingType (g_variant_get_type_string (value));
364 GList *iter = possibleSettingTypes;
365
366 while (iter)
367 {
368 *setting = attemptToFindCCSSettingFromLossyName (ccsGetPluginSettings (*plugin),
369 keyName,
370 (CCSSettingType) GPOINTER_TO_INT (iter->data));
371
372 if (*setting)
373 break;
374
375 iter = iter->next;
376 }
377
378 g_list_free (possibleSettingTypes);
379 g_variant_unref (value);
380 }
381 }
382 }
383
384 g_free (pluginName);
385
386 if (!*plugin || !*setting)
387 return FALSE;
388
389 return TRUE;
390}
391
392Bool
393updateSettingWithGSettingsKeyName (CCSBackend *backend,
394 GSettings *settings,
395 gchar *keyName,
396 CCSBackendUpdateFunc updateSetting)
397{
398 CCSContext *context = ccsGSettingsBackendGetContext (backend);
399 char *uncleanKeyName = NULL;
400 char *pathOrig;
401 CCSPlugin *plugin;
402 CCSSetting *setting;
403 Bool ret = TRUE;
404
405 g_object_get (G_OBJECT (settings), "path", &pathOrig, NULL);
406
407 if (findSettingAndPluginToUpdateFromPath (settings, pathOrig, keyName, context, &plugin, &setting, &uncleanKeyName))
408 (*updateSetting) (backend, context, plugin, setting);
409 else
410 {
411 /* We hit a situation where either the key stored in GSettings couldn't be
412 * matched at all to a key in the xml file, or where there were multiple matches.
413 * Unfortunately, there isn't much we can do about this, other than try
414 * and warn the user and bail out. It just means that if the key was updated
415 * externally we won't know about the change until the next reload of settings */
416 ccsWarning ("Unable to find setting %s, for path %s", uncleanKeyName, pathOrig);
417 ret = FALSE;
418 }
419
420 g_free (pathOrig);
421
422 if (uncleanKeyName)
423 free (uncleanKeyName);
424
425 return ret;
426}
427
331gchar *428gchar *
332makeCompizProfilePath (const gchar *profilename)429makeCompizProfilePath (const gchar *profilename)
333{430{
@@ -373,7 +470,7 @@
373}470}
374471
375GVariant *472GVariant *
376getVariantAtKey (GSettings *settings, char *key, const char *pathName, CCSSettingType type)473getVariantAtKey (GSettings *settings, const char *key, const char *pathName, CCSSettingType type)
377{474{
378 GVariant *gsettingsValue = g_settings_get_value (settings, key);475 GVariant *gsettingsValue = g_settings_get_value (settings, key);
379476
@@ -390,7 +487,7 @@
390readListValue (GVariant *gsettingsValue, CCSSettingType listType)487readListValue (GVariant *gsettingsValue, CCSSettingType listType)
391{488{
392 gboolean hasVariantType;489 gboolean hasVariantType;
393 unsigned int nItems, i = 0;490 unsigned int nItems;
394 CCSSettingValueList list = NULL;491 CCSSettingValueList list = NULL;
395 GVariantIter iter;492 GVariantIter iter;
396493
@@ -415,7 +512,7 @@
415512
416 /* Reads each item from the variant into arrayCounter */513 /* Reads each item from the variant into arrayCounter */
417 while (g_variant_iter_loop (&iter, "b", &value))514 while (g_variant_iter_loop (&iter, "b", &value))
418 *arrayCounter++ = value;515 *arrayCounter++ = value ? TRUE : FALSE;
419516
420 list = ccsGetValueListFromBoolArray (array, nItems, NULL);517 list = ccsGetValueListFromBoolArray (array, nItems, NULL);
421 free (array);518 free (array);
@@ -440,8 +537,8 @@
440 break;537 break;
441 case TypeFloat:538 case TypeFloat:
442 {539 {
443 double *array = malloc (nItems * sizeof (double));540 float *array = malloc (nItems * sizeof (float));
444 double *arrayCounter = array;541 float *arrayCounter = array;
445 gdouble value;542 gdouble value;
446543
447 if (!array)544 if (!array)
@@ -451,7 +548,7 @@
451 while (g_variant_iter_loop (&iter, "d", &value))548 while (g_variant_iter_loop (&iter, "d", &value))
452 *arrayCounter++ = value;549 *arrayCounter++ = value;
453550
454 list = ccsGetValueListFromFloatArray ((float *) array, nItems, NULL);551 list = ccsGetValueListFromFloatArray (array, nItems, NULL);
455 free (array);552 free (array);
456 }553 }
457 break;554 break;
@@ -477,18 +574,20 @@
477 break;574 break;
478 case TypeColor:575 case TypeColor:
479 {576 {
480 CCSSettingColorValue *array;
481 char *colorValue;577 char *colorValue;
482 array = malloc (nItems * sizeof (CCSSettingColorValue));578 CCSSettingColorValue *array = calloc (1, nItems * sizeof (CCSSettingColorValue));
579 unsigned int i = 0;
580
483 if (!array)581 if (!array)
484 break;582 break;
485583
486 while (g_variant_iter_loop (&iter, "s", &colorValue))584 while (g_variant_iter_loop (&iter, "s", &colorValue))
487 {585 {
488 memset (&array[i], 0, sizeof (CCSSettingColorValue));
489 ccsStringToColor (colorValue,586 ccsStringToColor (colorValue,
490 &array[i]);587 &array[i]);
588 i++;
491 }589 }
590
492 list = ccsGetValueListFromColorArray (array, nItems, NULL);591 list = ccsGetValueListFromColorArray (array, nItems, NULL);
493 free (array);592 free (array);
494 }593 }
@@ -667,7 +766,7 @@
667 return TRUE;766 return TRUE;
668}767}
669768
670Bool writeStringToVariant (char *value, GVariant **variant)769Bool writeStringToVariant (const char *value, GVariant **variant)
671{770{
672 *variant = g_variant_new_string (value);771 *variant = g_variant_new_string (value);
673 return TRUE;772 return TRUE;
@@ -744,3 +843,34 @@
744 free (edgeString);843 free (edgeString);
745 return TRUE;844 return TRUE;
746}845}
846
847void
848writeVariantToKey (GSettings *settings,
849 const char *key,
850 GVariant *value)
851{
852 g_settings_set_value (settings, key, value);
853}
854
855CCSContext *
856ccsGSettingsBackendGetContext (CCSBackend *backend)
857{
858 return (*(GET_INTERFACE (CCSGSettingsBackendInterface, backend))->gsettingsBackendGetContext) (backend);
859}
860
861
862void
863ccsGSettingsBackendConnectToChangedSignal (CCSBackend *backend,
864 GObject *object)
865{
866 (*(GET_INTERFACE (CCSGSettingsBackendInterface, backend))->gsettingsBackendConnectToChangedSignal) (backend, object);
867}
868
869GSettings *
870ccsGSettingsGetSettingsObjectForPluginWithPath (CCSBackend *backend,
871 const char *plugin,
872 const char *path,
873 CCSContext *context)
874{
875 return (*(GET_INTERFACE (CCSGSettingsBackendInterface, backend))->gsettingsBackendGetSettingsObjectForPluginWithPath) (backend, plugin, path, context);
876}
747877
=== modified file 'compizconfig/gsettings/gsettings_backend_shared/gsettings_util.h'
--- compizconfig/gsettings/gsettings_backend_shared/gsettings_util.h 2012-07-21 20:44:19 +0000
+++ compizconfig/gsettings/gsettings_backend_shared/gsettings_util.h 2012-07-21 20:44:20 +0000
@@ -1,10 +1,38 @@
1#ifndef _COMPIZ_GSETTINGS_UTIL_H1#ifndef _COMPIZ_GSETTINGS_UTIL_H
2#define _COMPIZ_GSETTINGS_UTIL_H2#define _COMPIZ_GSETTINGS_UTIL_H
33
4#include <ccs.h>
5#include <ccs-backend.h>
6
7COMPIZCONFIG_BEGIN_DECLS
8
4#include <glib.h>9#include <glib.h>
5#include <glib-object.h>10#include <glib-object.h>
6#include <gio/gio.h>11#include <gio/gio.h>
7#include <ccs.h>12
13typedef struct _CCSGSettingsBackendPrivate CCSGettingsBackendPrivate;
14typedef struct _CCSGSettingsBackendInterface CCSGSettingsBackendInterface;
15
16typedef CCSContext * (*CCSGSettingsBackendGetContext) (CCSBackend *);
17typedef void (*CCSGSettingsBackendConnectToChangedSignal) (CCSBackend *, GObject *);
18typedef GSettings * (*CCSGSettingsBackendGetSettingsObjectForPluginWithPath) (CCSBackend *backend,
19 const char *plugin,
20 const char *path,
21 CCSContext *context);
22
23struct _CCSGSettingsBackendInterface
24{
25 CCSGSettingsBackendGetContext gsettingsBackendGetContext;
26 CCSGSettingsBackendConnectToChangedSignal gsettingsBackendConnectToChangedSignal;
27 CCSGSettingsBackendGetSettingsObjectForPluginWithPath gsettingsBackendGetSettingsObjectForPluginWithPath;
28};
29
30struct _CCSGSettingsBackendPrivate
31{
32 CCSContext *context;
33};
34
35unsigned int ccsCCSGSettingsBackendInterfaceGetType ();
836
9gchar *37gchar *
10getSchemaNameForPlugin (const char *plugin);38getSchemaNameForPlugin (const char *plugin);
@@ -57,6 +85,20 @@
57CCSSetting *85CCSSetting *
58attemptToFindCCSSettingFromLossyName (CCSSettingList settingList, const gchar *lossyName, CCSSettingType type);86attemptToFindCCSSettingFromLossyName (CCSSettingList settingList, const gchar *lossyName, CCSSettingType type);
5987
88Bool
89findSettingAndPluginToUpdateFromPath (GSettings *settings,
90 const char *path,
91 const gchar *keyName,
92 CCSContext *context,
93 CCSPlugin **plugin,
94 CCSSetting **setting,
95 char **uncleanKeyName);
96
97Bool updateSettingWithGSettingsKeyName (CCSBackend *backend,
98 GSettings *settings,
99 gchar *keyName,
100 CCSBackendUpdateFunc updateSetting);
101
60GList *102GList *
61variantTypeToPossibleSettingType (const gchar *vt);103variantTypeToPossibleSettingType (const gchar *vt);
62104
@@ -73,7 +115,7 @@
73checkReadVariantIsValid (GVariant *gsettingsValue, CCSSettingType type, const gchar *pathName);115checkReadVariantIsValid (GVariant *gsettingsValue, CCSSettingType type, const gchar *pathName);
74116
75GVariant *117GVariant *
76getVariantAtKey (GSettings *settings, char *key, const char *pathName, CCSSettingType type);118getVariantAtKey (GSettings *settings, const char *key, const char *pathName, CCSSettingType type);
77119
78const char * readStringFromVariant (GVariant *gsettingsValue);120const char * readStringFromVariant (GVariant *gsettingsValue);
79121
@@ -99,7 +141,7 @@
99 CCSSettingType listType,141 CCSSettingType listType,
100 GVariant **gsettingsValue);142 GVariant **gsettingsValue);
101143
102Bool writeStringToVariant (char *value, GVariant **variant);144Bool writeStringToVariant (const char *value, GVariant **variant);
103145
104Bool writeFloatToVariant (float value, GVariant **variant);146Bool writeFloatToVariant (float value, GVariant **variant);
105147
@@ -115,4 +157,22 @@
115157
116Bool writeEdgeToVariant (unsigned int edges, GVariant **variant);158Bool writeEdgeToVariant (unsigned int edges, GVariant **variant);
117159
160void writeVariantToKey (GSettings *settings,
161 const char *key,
162 GVariant *value);
163
164CCSContext *
165ccsGSettingsBackendGetContext (CCSBackend *backend);
166
167void
168ccsGSettingsBackendConnectToChangedSignal (CCSBackend *backend, GObject *object);
169
170GSettings *
171ccsGSettingsGetSettingsObjectForPluginWithPath (CCSBackend *backend,
172 const char *plugin,
173 const char *path,
174 CCSContext *context);
175
176COMPIZCONFIG_END_DECLS
177
118#endif178#endif
119179
=== modified file 'compizconfig/gsettings/src/gconf-integration.c'
--- compizconfig/gsettings/src/gconf-integration.c 2012-07-21 20:44:19 +0000
+++ compizconfig/gsettings/src/gconf-integration.c 2012-07-21 20:44:20 +0000
@@ -537,7 +537,8 @@
537}537}
538538
539Bool539Bool
540readGConfIntegratedOption (CCSContext *context,540readGConfIntegratedOption (CCSBackend *backend,
541 CCSContext *context,
541 CCSSetting *setting,542 CCSSetting *setting,
542 int index)543 int index)
543{544{
@@ -545,7 +546,7 @@
545 GError *err = NULL;546 GError *err = NULL;
546 Bool ret = FALSE;547 Bool ret = FALSE;
547 548
548 ret = readOption (setting);549 ret = readOption (backend, setting);
549550
550 gconfValue = gconf_client_get (client,551 gconfValue = gconf_client_get (client,
551 specialOptions[index].gnomeName,552 specialOptions[index].gnomeName,
@@ -765,7 +766,8 @@
765}766}
766767
767void768void
768writeGConfIntegratedOption (CCSContext *context,769writeGConfIntegratedOption (CCSBackend *backend,
770 CCSContext *context,
769 CCSSetting *setting,771 CCSSetting *setting,
770 int index)772 int index)
771{773{
772774
=== modified file 'compizconfig/gsettings/src/gsettings.c'
--- compizconfig/gsettings/src/gsettings.c 2012-07-21 20:44:19 +0000
+++ compizconfig/gsettings/src/gsettings.c 2012-07-21 20:44:20 +0000
@@ -46,15 +46,20 @@
4646
47char *currentProfile = NULL;47char *currentProfile = NULL;
4848
49/* This will need to be rempved */
50CCSContext *storedContext = NULL;
51
49/* some forward declarations */52/* some forward declarations */
50static void writeIntegratedOption (CCSContext *context,53static void writeIntegratedOption (CCSBackend *backend,
54 CCSContext *context,
51 CCSSetting *setting,55 CCSSetting *setting,
52 int index);56 int index);
5357
54static GSettings *58static GSettings *
55getSettingsObjectForPluginWithPath (const char *plugin,59ccsGSettingsBackendGetSettingsObjectForPluginWithPathDefault (CCSBackend *backend,
56 const char *path,60 const char *plugin,
57 CCSContext *context)61 const char *path,
62 CCSContext *context)
58{63{
59 GSettings *settingsObj = NULL;64 GSettings *settingsObj = NULL;
60 gchar *schemaName = getSchemaNameForPlugin (plugin);65 gchar *schemaName = getSchemaNameForPlugin (plugin);
@@ -74,7 +79,7 @@
74 79
75 settingsObj = g_settings_new_with_path (schemaName, path);80 settingsObj = g_settings_new_with_path (schemaName, path);
7681
77 g_signal_connect (G_OBJECT (settingsObj), "changed", (GCallback) valueChanged, (gpointer) context);82 ccsGSettingsBackendConnectToChangedSignal (backend, G_OBJECT (settingsObj));
7883
79 settingsList = g_list_append (settingsList, (void *) settingsObj);84 settingsList = g_list_append (settingsList, (void *) settingsObj);
8085
@@ -104,14 +109,15 @@
104}109}
105110
106static GSettings *111static GSettings *
107getSettingsObjectForCCSSetting (CCSSetting *setting)112getSettingsObjectForCCSSetting (CCSBackend *backend, CCSSetting *setting)
108{113{
109 GSettings *ret = NULL;114 GSettings *ret = NULL;
110 gchar *pathName = makeSettingPath (setting);115 gchar *pathName = makeSettingPath (setting);
111116
112 ret = getSettingsObjectForPluginWithPath (ccsPluginGetName (ccsSettingGetParent (setting)),117 ret = ccsGSettingsGetSettingsObjectForPluginWithPath (backend,
113 pathName,118 ccsPluginGetName (ccsSettingGetParent (setting)),
114 ccsPluginGetContext (ccsSettingGetParent (setting)));119 pathName,
120 ccsPluginGetContext (ccsSettingGetParent (setting)));
115121
116 g_free (pathName);122 g_free (pathName);
117 return ret;123 return ret;
@@ -129,113 +135,57 @@
129}135}
130136
131static void137static void
138updateSetting (CCSBackend *backend, CCSContext *context, CCSPlugin *plugin, CCSSetting *setting)
139{
140 int index;
141
142 readInit (backend, context);
143 if (!readOption (backend, setting))
144 {
145 ccsResetToDefault (setting, TRUE);
146 }
147
148 if (ccsGetIntegrationEnabled (context) &&
149 isIntegratedOption (setting, &index))
150 {
151 writeInit (backend, context);
152 writeIntegratedOption (backend, context, setting, index);
153 }
154}
155
156static void
132valueChanged (GSettings *settings,157valueChanged (GSettings *settings,
133 gchar *keyName,158 gchar *keyName,
134 gpointer user_data)159 gpointer user_data)
135{160{
136 CCSContext *context = (CCSContext *)user_data;161 CCSBackend *backend = (CCSBackend *)user_data;
137 char *uncleanKeyName;162
138 char *path, *pathOrig;163 updateSettingWithGSettingsKeyName (backend, settings, keyName, updateSetting);
139 char *pluginName;
140 int index;
141 unsigned int screenNum;
142 CCSPlugin *plugin;
143 CCSSetting *setting;
144
145 g_object_get (G_OBJECT (settings), "path", &pathOrig, NULL);
146
147 path = pathOrig;
148
149 if (!decomposeGSettingsPath (path, &pluginName, &screenNum))
150 {
151 g_free (pathOrig);
152 return;
153 }
154
155 plugin = ccsFindPlugin (context, pluginName);
156
157 uncleanKeyName = translateKeyForCCS (keyName);
158
159 setting = ccsFindSetting (plugin, uncleanKeyName);
160 if (!setting)
161 {
162 /* Couldn't find setting straight off the bat,
163 * try and find the best match */
164 GVariant *value = g_settings_get_value (settings, keyName);
165
166 if (value)
167 {
168 GList *possibleSettingTypes = variantTypeToPossibleSettingType (g_variant_get_type_string (value));
169 GList *iter = possibleSettingTypes;
170
171 while (iter)
172 {
173 setting = attemptToFindCCSSettingFromLossyName (ccsGetPluginSettings (plugin),
174 keyName,
175 (CCSSettingType) GPOINTER_TO_INT (iter->data));
176
177 if (setting)
178 break;
179
180 iter = iter->next;
181 }
182
183 g_list_free (possibleSettingTypes);
184 g_variant_unref (value);
185 }
186
187 /* We hit a situation where either the key stored in GSettings couldn't be
188 * matched at all to a key in the xml file, or where there were multiple matches.
189 * Unfortunately, there isn't much we can do about this, other than try
190 * and warn the user and bail out. It just means that if the key was updated
191 * externally we won't know about the change until the next reload of settings */
192 if (!setting)
193 {
194 ccsWarning ("Unable to find setting %s, for path %s", uncleanKeyName, path);
195 g_free (pluginName);
196 free (uncleanKeyName);
197 g_free (pathOrig);
198 return;
199 }
200 }
201
202 readInit (NULL, context);
203 if (!readOption (setting))
204 {
205 ccsResetToDefault (setting, TRUE);
206 }
207
208 if (ccsGetIntegrationEnabled (context) &&
209 isIntegratedOption (setting, &index))
210 {
211 writeInit (NULL, context);
212 writeIntegratedOption (context, setting, index);
213 }
214
215 g_free (pluginName);
216 free (uncleanKeyName);
217 g_free (pathOrig);
218}164}
219165
220static Bool166static Bool
221readIntegratedOption (CCSContext *context,167readIntegratedOption (CCSBackend *backend,
168 CCSContext *context,
222 CCSSetting *setting,169 CCSSetting *setting,
223 int index)170 int index)
224{171{
225#ifdef USE_GCONF172#ifdef USE_GCONF
226 return readGConfIntegratedOption (context, setting, index);173 return readGConfIntegratedOption (backend, context, setting, index);
227#else174#else
228 return FALSE;175 return FALSE;
229#endif176#endif
230}177}
231178
232static GVariant *179static GVariant *
233getVariantForCCSSetting (CCSSetting *setting)180getVariantForCCSSetting (CCSBackend *backend, CCSSetting *setting)
234{181{
235 GSettings *settings = getSettingsObjectForCCSSetting (setting);182 GSettings *settings = getSettingsObjectForCCSSetting (backend, setting);
236 char *cleanSettingName = getNameForCCSSetting (setting);183 char *cleanSettingName = getNameForCCSSetting (setting);
237 gchar *pathName = makeSettingPath (setting);184 gchar *pathName = makeSettingPath (setting);
238 GVariant *gsettingsValue = getVariantAtKey (settings, cleanSettingName, pathName, ccsSettingGetType (setting));185 GVariant *gsettingsValue = getVariantAtKey (settings,
186 cleanSettingName,
187 pathName,
188 ccsSettingGetType (setting));
239189
240 free (cleanSettingName);190 free (cleanSettingName);
241 free (pathName);191 free (pathName);
@@ -243,7 +193,7 @@
243}193}
244194
245Bool195Bool
246readOption (CCSSetting * setting)196readOption (CCSBackend *backend, CCSSetting * setting)
247{197{
248 Bool ret = FALSE;198 Bool ret = FALSE;
249 GVariant *gsettingsValue = NULL;199 GVariant *gsettingsValue = NULL;
@@ -259,7 +209,7 @@
259 return FALSE;209 return FALSE;
260 }210 }
261211
262 gsettingsValue = getVariantForCCSSetting (setting);212 gsettingsValue = getVariantForCCSSetting (backend, setting);
263213
264 switch (ccsSettingGetType (setting))214 switch (ccsSettingGetType (setting))
265 {215 {
@@ -397,21 +347,22 @@
397}347}
398348
399static void349static void
400writeIntegratedOption (CCSContext *context,350writeIntegratedOption (CCSBackend *backend,
351 CCSContext *context,
401 CCSSetting *setting,352 CCSSetting *setting,
402 int index)353 int index)
403{354{
404#ifdef USE_GCONF355#ifdef USE_GCONF
405 writeGConfIntegratedOption (context, setting, index);356 writeGConfIntegratedOption (backend, context, setting, index);
406#endif357#endif
407358
408 return;359 return;
409}360}
410361
411static void362static void
412resetOptionToDefault (CCSSetting * setting)363resetOptionToDefault (CCSBackend *backend, CCSSetting * setting)
413{364{
414 GSettings *settings = getSettingsObjectForCCSSetting (setting);365 GSettings *settings = getSettingsObjectForCCSSetting (backend, setting);
415 366
416 char *cleanSettingName = translateKeyForGSettings (ccsSettingGetName (setting));367 char *cleanSettingName = translateKeyForGSettings (ccsSettingGetName (setting));
417368
@@ -421,9 +372,9 @@
421}372}
422373
423void374void
424writeOption (CCSSetting * setting)375writeOption (CCSBackend *backend, CCSSetting * setting)
425{376{
426 GSettings *settings = getSettingsObjectForCCSSetting (setting);377 GSettings *settings = getSettingsObjectForCCSSetting (backend, setting);
427 char *cleanSettingName = translateKeyForGSettings (ccsSettingGetName (setting));378 char *cleanSettingName = translateKeyForGSettings (ccsSettingGetName (setting));
428 GVariant *gsettingsValue = NULL;379 GVariant *gsettingsValue = NULL;
429 Bool success = FALSE;380 Bool success = FALSE;
@@ -447,6 +398,7 @@
447 success = writeStringToVariant (value, &gsettingsValue);398 success = writeStringToVariant (value, &gsettingsValue);
448 }399 }
449 }400 }
401 break;
450 case TypeFloat:402 case TypeFloat:
451 {403 {
452 float value;404 float value;
@@ -525,7 +477,6 @@
525 break;477 break;
526 case TypeList:478 case TypeList:
527 {479 {
528 GVariant *value = NULL;
529 CCSSettingValueList list = NULL;480 CCSSettingValueList list = NULL;
530481
531 if (!ccsGetList (setting, &list))482 if (!ccsGetList (setting, &list))
@@ -533,7 +484,7 @@
533484
534 success = writeListValue (list,485 success = writeListValue (list,
535 ccsSettingGetInfo (setting)->forList.listType,486 ccsSettingGetInfo (setting)->forList.listType,
536 &value);487 &gsettingsValue);
537 }488 }
538 break;489 break;
539 default:490 default:
@@ -546,7 +497,7 @@
546 {497 {
547 /* g_settings_set_value will consume the reference498 /* g_settings_set_value will consume the reference
548 * so there is no need to unref value here */499 * so there is no need to unref value here */
549 g_settings_set_value (settings, cleanSettingName, gsettingsValue);500 writeVariantToKey (settings, cleanSettingName, gsettingsValue);
550 }501 }
551502
552 free (cleanSettingName);503 free (cleanSettingName);
@@ -644,6 +595,24 @@
644 }595 }
645}596}
646597
598static CCSContext *
599ccsGSettingsBackendGetContextDefault (CCSBackend *backend)
600{
601 return storedContext;
602}
603
604static void
605ccsGSettingsBackendConnectToValueChangedSignalDefault (CCSBackend *backend, GObject *object)
606{
607 g_signal_connect (object, "changed", (GCallback) valueChanged, (gpointer) backend);
608}
609
610static CCSGSettingsBackendInterface gsettingsAdditionalDefaultInterface = {
611 ccsGSettingsBackendGetContextDefault,
612 ccsGSettingsBackendConnectToValueChangedSignalDefault,
613 ccsGSettingsBackendGetSettingsObjectForPluginWithPathDefault
614};
615
647static Bool616static Bool
648initBackend (CCSBackend *backend, CCSContext * context)617initBackend (CCSBackend *backend, CCSContext * context)
649{618{
@@ -663,6 +632,10 @@
663632
664 g_free (currentProfilePath);633 g_free (currentProfilePath);
665634
635 storedContext = context;
636
637 ccsObjectAddInterface (backend, (CCSInterface *) &gsettingsAdditionalDefaultInterface, GET_INTERFACE_TYPE (CCSGSettingsBackendInterface));
638
666 return TRUE;639 return TRUE;
667}640}
668641
@@ -690,6 +663,8 @@
690 l = g_list_next (l);663 l = g_list_next (l);
691 }664 }
692665
666 settingsList = NULL;
667
693 if (currentProfileSettings)668 if (currentProfileSettings)
694 {669 {
695 g_object_unref (currentProfileSettings);670 g_object_unref (currentProfileSettings);
@@ -698,6 +673,8 @@
698673
699 g_object_unref (G_OBJECT (compizconfigSettings));674 g_object_unref (G_OBJECT (compizconfigSettings));
700675
676 compizconfigSettings = NULL;
677
701 processEvents (backend, 0);678 processEvents (backend, 0);
702 return TRUE;679 return TRUE;
703}680}
@@ -719,10 +696,10 @@
719 if (ccsGetIntegrationEnabled (context) &&696 if (ccsGetIntegrationEnabled (context) &&
720 isIntegratedOption (setting, &index))697 isIntegratedOption (setting, &index))
721 {698 {
722 status = readIntegratedOption (context, setting, index);699 status = readIntegratedOption (backend, context, setting, index);
723 }700 }
724 else701 else
725 status = readOption (setting);702 status = readOption (backend, setting);
726703
727 if (!status)704 if (!status)
728 ccsResetToDefault (setting, TRUE);705 ccsResetToDefault (setting, TRUE);
@@ -744,14 +721,14 @@
744 if (ccsGetIntegrationEnabled (context) &&721 if (ccsGetIntegrationEnabled (context) &&
745 isIntegratedOption (setting, &index))722 isIntegratedOption (setting, &index))
746 {723 {
747 writeIntegratedOption (context, setting, index);724 writeIntegratedOption (backend, context, setting, index);
748 }725 }
749 else if (ccsSettingGetIsDefault (setting))726 else if (ccsSettingGetIsDefault (setting))
750 {727 {
751 resetOptionToDefault (setting);728 resetOptionToDefault (backend, setting);
752 }729 }
753 else730 else
754 writeOption (setting);731 writeOption (backend, setting);
755732
756}733}
757734
@@ -821,7 +798,7 @@
821 GSettings *settings;798 GSettings *settings;
822 gchar *pathName = makeCompizPluginPath (currentProfile, plugin);799 gchar *pathName = makeCompizPluginPath (currentProfile, plugin);
823800
824 settings = getSettingsObjectForPluginWithPath (plugin, pathName, context);801 settings = ccsGSettingsGetSettingsObjectForPluginWithPath (backend, plugin, pathName, context);
825 g_free (pathName);802 g_free (pathName);
826803
827 /* The GSettings documentation says not to use this API804 /* The GSettings documentation says not to use this API
@@ -916,12 +893,15 @@
916 writeInit,893 writeInit,
917 writeSetting,894 writeSetting,
918 0,895 0,
896 updateSetting,
919 getSettingIsIntegrated,897 getSettingIsIntegrated,
920 getSettingIsReadOnly,898 getSettingIsReadOnly,
921 getExistingProfiles,899 getExistingProfiles,
922 deleteProfile900 deleteProfile
923};901};
924902
903
904
925CCSBackendInterface *905CCSBackendInterface *
926getBackendInfo (void)906getBackendInfo (void)
927{907{
928908
=== modified file 'compizconfig/gsettings/src/gsettings.h'
--- compizconfig/gsettings/src/gsettings.h 2012-07-21 20:44:19 +0000
+++ compizconfig/gsettings/src/gsettings.h 2012-07-21 20:44:20 +0000
@@ -68,9 +68,9 @@
6868
69Bool readInit (CCSBackend *, CCSContext * context);69Bool readInit (CCSBackend *, CCSContext * context);
70void readSetting (CCSBackend *, CCSContext * context, CCSSetting * setting);70void readSetting (CCSBackend *, CCSContext * context, CCSSetting * setting);
71Bool readOption (CCSSetting * setting);71Bool readOption (CCSBackend *backend, CCSSetting * setting);
72Bool writeInit (CCSBackend *, CCSContext * context);72Bool writeInit (CCSBackend *, CCSContext * context);
73void writeOption (CCSSetting *setting);73void writeOption (CCSBackend *backend, CCSSetting *setting);
7474
75#ifdef USE_GCONF75#ifdef USE_GCONF
7676
@@ -106,12 +106,14 @@
106finiGConfClient (void);106finiGConfClient (void);
107107
108Bool108Bool
109readGConfIntegratedOption (CCSContext *context,109readGConfIntegratedOption (CCSBackend *backend,
110 CCSContext *context,
110 CCSSetting *setting,111 CCSSetting *setting,
111 int index);112 int index);
112113
113void114void
114writeGConfIntegratedOption (CCSContext *context,115writeGConfIntegratedOption (CCSBackend *backend,
116 CCSContext *context,
115 CCSSetting *setting,117 CCSSetting *setting,
116 int index);118 int index);
117119
118120
=== modified file 'compizconfig/gsettings/tests/CMakeLists.txt'
--- compizconfig/gsettings/tests/CMakeLists.txt 2012-07-21 20:44:19 +0000
+++ compizconfig/gsettings/tests/CMakeLists.txt 2012-07-21 20:44:20 +0000
@@ -1,10 +1,16 @@
1include (CompizGSettings)
2
1include_directories (${CMAKE_CURRENT_SOURCE_DIR}3include_directories (${CMAKE_CURRENT_SOURCE_DIR}
4 ${CMAKE_CURRENT_BINARY_DIR}
2 ${CMAKE_CURRENT_SOURCE_DIR}/../src5 ${CMAKE_CURRENT_SOURCE_DIR}/../src
3 ${CMAKE_CURRENT_SOURCE_DIR}/../../libcompizconfig/tests6 ${CMAKE_CURRENT_SOURCE_DIR}/../../libcompizconfig/tests
4 ${CMAKE_CURRENT_SOURCE_DIR}/../../mocks/libcompizconfig)7 ${CMAKE_CURRENT_SOURCE_DIR}/../../mocks/libcompizconfig
8 ${CMAKE_CURRENT_SOURCE_DIR}/../../tests)
59
6pkg_check_modules (COMPIZCONFIG_TEST_GSETTINGS libcompizconfig)10pkg_check_modules (COMPIZCONFIG_TEST_GSETTINGS libcompizconfig)
711
12link_directories (${CMAKE_CURRENT_BINARY_DIR}/../../libcompizconfig/tests)
13
8add_executable (compizconfig_test_gsettings14add_executable (compizconfig_test_gsettings
9 ${CMAKE_CURRENT_SOURCE_DIR}/gsettings_mocks.cpp15 ${CMAKE_CURRENT_SOURCE_DIR}/gsettings_mocks.cpp
10 ${CMAKE_CURRENT_SOURCE_DIR}/test_gsettings_tests.cpp16 ${CMAKE_CURRENT_SOURCE_DIR}/test_gsettings_tests.cpp
@@ -12,7 +18,8 @@
12 ${CMAKE_CURRENT_SOURCE_DIR}/gsettings_mocks.h18 ${CMAKE_CURRENT_SOURCE_DIR}/gsettings_mocks.h
13 ${CMAKE_CURRENT_SOURCE_DIR}/test_gsettings_tests.h)19 ${CMAKE_CURRENT_SOURCE_DIR}/test_gsettings_tests.h)
1420
15link_directories (${CMAKE_CURRENT_BINARY_DIR}/../../libcompizconfig/tests)21add_executable (compizconfig_test_gsettings_conformance
22 ${CMAKE_CURRENT_SOURCE_DIR}/test_gsettings_conformance.cpp)
1623
17target_link_libraries (compizconfig_test_gsettings24target_link_libraries (compizconfig_test_gsettings
18 gsettings_backend_shared25 gsettings_backend_shared
@@ -21,4 +28,27 @@
21 ${GTEST_BOTH_LIBRARIES}28 ${GTEST_BOTH_LIBRARIES}
22 ${GMOCK_MAIN_LIBRARY})29 ${GMOCK_MAIN_LIBRARY})
2330
31configure_file (${CMAKE_CURRENT_SOURCE_DIR}/backend-conformance-config.h.in
32 ${CMAKE_CURRENT_BINARY_DIR}/backend-conformance-config.h)
33
34add_custom_command (OUTPUT ${CMAKE_BINARY_DIR}/generated/glib-2.0/schemas/org.compiz.mock.gschema.xml
35 COMMAND cp -r ${CMAKE_CURRENT_SOURCE_DIR}/org.compiz.mock.gschema.xml ${CMAKE_BINARY_DIR}/generated/glib-2.0/schemas/org.compiz.mock.gschema.xml
36 DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/org.compiz.mock.gschema.xml
37 VERBATIM)
38
39add_custom_target (compiz_gsettings_mock_schema ALL
40 DEPENDS ${CMAKE_BINARY_DIR}/generated/glib-2.0/schemas/org.compiz.mock.gschema.xml)
41
42add_gsettings_schema_to_recompilation_list (compiz_gsettings_mock_schema)
43
44target_link_libraries (compizconfig_test_gsettings_conformance
45 gsettings_backend_shared
46 compizconfig_ccs_setting_mock
47 compizconfig_ccs_plugin_mock
48 compizconfig_ccs_context_mock
49 ${COMPIZCONFIG_TEST_GSETTINGS_LIBRARIES}
50 ${GTEST_BOTH_LIBRARIES}
51 ${GMOCK_MAIN_LIBRARY})
52
24compiz_discover_tests (compizconfig_test_gsettings)53compiz_discover_tests (compizconfig_test_gsettings)
54compiz_discover_tests (compizconfig_test_gsettings_conformance)
2555
=== added file 'compizconfig/gsettings/tests/backend-conformance-config.h.in'
--- compizconfig/gsettings/tests/backend-conformance-config.h.in 1970-01-01 00:00:00 +0000
+++ compizconfig/gsettings/tests/backend-conformance-config.h.in 2012-07-21 20:44:20 +0000
@@ -0,0 +1,2 @@
1#define BACKEND_BINARY_PATH "@CMAKE_BINARY_DIR@/compizconfig/gsettings"
2#define MOCK_SCHEMA_PATH "@CMAKE_BINARY_DIR@/generated/glib-2.0/schemas"
03
=== added file 'compizconfig/gsettings/tests/org.compiz.mock.gschema.xml'
--- compizconfig/gsettings/tests/org.compiz.mock.gschema.xml 1970-01-01 00:00:00 +0000
+++ compizconfig/gsettings/tests/org.compiz.mock.gschema.xml 2012-07-21 20:44:20 +0000
@@ -0,0 +1,50 @@
1<?xml version="1.0"?>
2<schemalist>
3 <schema id="org.compiz.mock" gettext-domain="compiz">
4 <key type="i" name="integer-setting">
5 <default>0</default>
6 </key>
7 <key type="b" name="boolean-setting">
8 <default>false</default>
9 </key>
10 <key type="d" name="float-setting">
11 <default>0.0</default>
12 </key>
13 <key type="s" name="string-setting">
14 <default>""</default>
15 </key>
16 <key type="s" name="match-setting">
17 <default>""</default>
18 </key>
19 <key type="b" name="bell-setting">
20 <default>false</default>
21 </key>
22 <key type="s" name="color-setting">
23 <default>""</default>
24 </key>
25 <key type="s" name="key-setting">
26 <default>""</default>
27 </key>
28 <key type="s" name="button-setting">
29 <default>""</default>
30 </key>
31 <key type="s" name="edge-setting">
32 <default>""</default>
33 </key>
34 <key type="ai" name="int-list-setting">
35 <default>[0]</default>
36 </key>
37 <key type="ad" name="float-list-setting">
38 <default>[0.0]</default>
39 </key>
40 <key type="ab" name="bool-list-setting">
41 <default>[true]</default>
42 </key>
43 <key type="as" name="string-list-setting">
44 <default>[""]</default>
45 </key>
46 <key type="as" name="color-list-setting">
47 <default>[""]</default>
48 </key>
49 </schema>
50</schemalist>
051
=== added file 'compizconfig/gsettings/tests/test_gsettings_conformance.cpp'
--- compizconfig/gsettings/tests/test_gsettings_conformance.cpp 1970-01-01 00:00:00 +0000
+++ compizconfig/gsettings/tests/test_gsettings_conformance.cpp 2012-07-21 20:44:20 +0000
@@ -0,0 +1,431 @@
1#include <gtest/gtest.h>
2#include <gmock/gmock.h>
3
4#include <gsettings_util.h>
5
6#include <gio/gio.h>
7
8#include "backend-conformance-config.h"
9
10#include <ccs.h>
11#include <compizconfig_backend_concept_test.h>
12
13#include <iostream>
14
15using ::testing::AtLeast;
16using ::testing::Pointee;
17using ::testing::ReturnNull;
18
19namespace
20{
21const std::string MOCK_SCHEMA ("org.compiz.mock");
22const std::string MOCK_PATH (MOCK_SCHEMA_PATH);
23}
24
25class CCSGSettingsBackendEnv :
26 public CCSBackendConceptTestEnvironmentInterface
27{
28 public:
29
30 CCSGSettingsBackendEnv () :
31 pluginToMatch ("mock")
32 {
33 g_type_init ();
34 }
35
36 /* A wrapper to prevent signals from being added */
37 static void connectToSignalWrapper (CCSBackend *backend, GObject *object)
38 {
39 };
40
41 CCSBackend * SetUp (CCSContext *context, CCSContextGMock *gmockContext)
42 {
43 CCSBackendInterface *interface = NULL;
44 Bool fallback = FALSE;
45
46 g_setenv ("GSETTINGS_SCHEMA_DIR", MOCK_PATH.c_str (), true);
47 g_setenv ("GSETTINGS_BACKEND", "memory", true);
48 g_setenv ("LIBCOMPIZCONFIG_BACKEND_PATH", BACKEND_BINARY_PATH, true);
49
50 mContext = context;
51
52 std::string path ("gsettings");
53
54 void *dlhand = ccsOpenBackend (path.c_str (), &interface, &fallback);
55
56 EXPECT_FALSE (fallback);
57 EXPECT_TRUE (dlhand);
58
59 mGSettingsBackend = ccsBackendNewWithInterface (mContext, interface, dlhand);
60 mBackend = ccsBackendWithCapabilitiesWrapBackend (&ccsDefaultInterfaceTable, mGSettingsBackend);
61
62 CCSBackendInitFunc backendInit = (GET_INTERFACE (CCSBackendInterface, mBackend))->backendInit;
63
64 if (backendInit)
65 (*backendInit) ((CCSBackend *) mBackend, mContext);
66
67 overloadedInterface = *(GET_INTERFACE (CCSGSettingsBackendInterface, mGSettingsBackend));
68 overloadedInterface.gsettingsBackendConnectToChangedSignal = CCSGSettingsBackendEnv::connectToSignalWrapper;
69
70 ccsObjectRemoveInterface (mGSettingsBackend, GET_INTERFACE_TYPE (CCSGSettingsBackendInterface));
71 ccsObjectAddInterface (mGSettingsBackend, (CCSInterface *) &overloadedInterface, GET_INTERFACE_TYPE (CCSGSettingsBackendInterface));
72
73 mSettings = ccsGSettingsGetSettingsObjectForPluginWithPath (mGSettingsBackend, "mock", makeCompizPluginPath (profileName.c_str (), "mock"), mContext);
74
75 ON_CALL (*gmockContext, getProfile ()).WillByDefault (Return (profileName.c_str ()));
76
77 return (CCSBackend *) mBackend;
78 }
79
80 void TearDown (CCSBackend *)
81 {
82 g_unsetenv ("GSETTINGS_SCHEMA_DIR");
83 g_unsetenv ("GSETTINGS_BACKEND");
84 g_unsetenv ("LIBCOMPIZCONFIG_BACKEND_PATH");
85
86 ccsFreeBackendWithCapabilities (mBackend);
87 }
88
89 void PreWrite (CCSContextGMock *gmockContext,
90 CCSPluginGMock *gmockPlugin,
91 CCSSettingGMock *gmockSetting,
92 CCSSettingType type)
93 {
94 EXPECT_CALL (*gmockContext, getIntegrationEnabled ()).WillRepeatedly (Return (FALSE));
95 EXPECT_CALL (*gmockPlugin, getContext ()).Times (AtLeast (1));
96 EXPECT_CALL (*gmockPlugin, getName ()).Times (AtLeast (1));
97 EXPECT_CALL (*gmockSetting, getType ()).Times (AtLeast (1));
98 EXPECT_CALL (*gmockSetting, getName ()).Times (AtLeast (1));
99 EXPECT_CALL (*gmockSetting, getParent ()).Times (AtLeast (1));
100 EXPECT_CALL (*gmockSetting, getIsDefault ()).WillRepeatedly (Return (FALSE));
101 }
102
103 void PostWrite (CCSContextGMock *gmockContext,
104 CCSPluginGMock *gmockPlugin,
105 CCSSettingGMock *gmockSetting,
106 CCSSettingType type) {}
107
108 void WriteBoolAtKey (const std::string &plugin,
109 const std::string &key,
110 const VariantTypes &value)
111 {
112 GVariant *variant = NULL;
113 if (writeBoolToVariant (boolToBool (boost::get <bool> (value)), &variant))
114 writeVariantToKey (mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant);
115 else
116 throw std::exception ();
117 }
118
119 void WriteIntegerAtKey (const std::string &plugin,
120 const std::string &key,
121 const VariantTypes &value)
122 {
123 GVariant *variant = NULL;
124 if (writeIntToVariant (boost::get <int> (value), &variant))
125 writeVariantToKey (mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant);
126 else
127 throw std::exception ();
128 }
129
130 void WriteFloatAtKey (const std::string &plugin,
131 const std::string &key,
132 const VariantTypes &value)
133 {
134 GVariant *variant = NULL;
135 if (writeFloatToVariant (boost::get <float> (value), &variant))
136 writeVariantToKey (mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant);
137 else
138 throw std::exception ();
139 }
140
141 void WriteStringAtKey (const std::string &plugin,
142 const std::string &key,
143 const VariantTypes &value)
144 {
145 GVariant *variant = NULL;
146 if (writeStringToVariant (boost::get <const char *> (value), &variant))
147 writeVariantToKey (mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant);
148 else
149 throw std::exception ();
150 }
151
152 void WriteColorAtKey (const std::string &plugin,
153 const std::string &key,
154 const VariantTypes &value)
155 {
156 GVariant *variant = NULL;
157 if (writeColorToVariant (boost::get <CCSSettingColorValue> (value), &variant))
158 writeVariantToKey (mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant);
159 else
160 throw std::exception ();
161 }
162
163 void WriteKeyAtKey (const std::string &plugin,
164 const std::string &key,
165 const VariantTypes &value)
166 {
167 GVariant *variant = NULL;
168 if (writeKeyToVariant (boost::get <CCSSettingKeyValue> (value), &variant))
169 writeVariantToKey (mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant);
170 else
171 throw std::exception ();
172 }
173
174 void WriteButtonAtKey (const std::string &plugin,
175 const std::string &key,
176 const VariantTypes &value)
177 {
178 GVariant *variant = NULL;
179 if (writeButtonToVariant (boost::get <CCSSettingButtonValue> (value), &variant))
180 writeVariantToKey (mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant);
181 else
182 throw std::exception ();
183 }
184
185 void WriteEdgeAtKey (const std::string &plugin,
186 const std::string &key,
187 const VariantTypes &value)
188 {
189 GVariant *variant = NULL;
190 if (writeEdgeToVariant (boost::get <unsigned int> (value), &variant))
191 writeVariantToKey (mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant);
192 else
193 throw std::exception ();
194 }
195
196 void WriteMatchAtKey (const std::string &plugin,
197 const std::string &key,
198 const VariantTypes &value)
199 {
200 GVariant *variant = NULL;
201 if (writeStringToVariant (boost::get <const char *> (value), &variant))
202 writeVariantToKey (mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant);
203 else
204 throw std::exception ();
205 }
206
207 void WriteBellAtKey (const std::string &plugin,
208 const std::string &key,
209 const VariantTypes &value)
210 {
211 GVariant *variant = NULL;
212 if (writeBoolToVariant (boolToBool (boost::get <bool> (value)), &variant))
213 writeVariantToKey (mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant);
214 else
215 throw std::exception ();
216 }
217
218 void WriteListAtKey (const std::string &plugin,
219 const std::string &key,
220 const VariantTypes &value)
221 {
222 GVariant *variant = NULL;
223
224 const CCSListWrapper::Ptr &lw (boost::get <CCSListWrapper::Ptr> (value));
225
226 if (writeListValue (*lw, lw->type (), &variant))
227 writeVariantToKey (mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant);
228 else
229 throw std::exception ();
230 }
231
232 void PreRead (CCSContextGMock *gmockContext,
233 CCSPluginGMock *gmockPlugin,
234 CCSSettingGMock *gmockSetting,
235 CCSSettingType type)
236 {
237 EXPECT_CALL (*gmockContext, getIntegrationEnabled ()).WillOnce (Return (FALSE));
238 EXPECT_CALL (*gmockPlugin, getContext ()).Times (AtLeast (1));
239 EXPECT_CALL (*gmockPlugin, getName ()).Times (AtLeast (1));
240 EXPECT_CALL (*gmockSetting, getType ()).Times (AtLeast (1));
241 EXPECT_CALL (*gmockSetting, getName ()).Times (AtLeast (1));
242 EXPECT_CALL (*gmockSetting, getParent ()).Times (AtLeast (1));
243 EXPECT_CALL (*gmockSetting, isReadOnly ()).WillRepeatedly (Return (FALSE));
244
245 if (type == TypeList)
246 {
247 EXPECT_CALL (*gmockSetting, getInfo ()).Times (AtLeast (1));
248 EXPECT_CALL (*gmockSetting, getDefaultValue ()).WillRepeatedly (ReturnNull ());
249 }
250 }
251
252 void PostRead (CCSContextGMock *gmockContext,
253 CCSPluginGMock *gmockPlugin,
254 CCSSettingGMock *gmockSetting,
255 CCSSettingType type) {}
256
257 Bool ReadBoolAtKey (const std::string &plugin,
258 const std::string &key)
259 {
260 GVariant *variant = getVariantAtKey (mSettings,
261 CharacterWrapper (translateKeyForGSettings (key.c_str ())),
262 CharacterWrapper (makeCompizPluginPath (profileName.c_str (), plugin.c_str ())),
263 TypeBool);
264 return readBoolFromVariant (variant);
265 }
266
267 int ReadIntegerAtKey (const std::string &plugin,
268 const std::string &key)
269 {
270 GVariant *variant = getVariantAtKey (mSettings,
271 CharacterWrapper (translateKeyForGSettings (key.c_str ())),
272 CharacterWrapper (makeCompizPluginPath (profileName.c_str (), plugin.c_str ())),
273 TypeInt);
274 return readIntFromVariant (variant);
275 }
276
277 float ReadFloatAtKey (const std::string &plugin,
278 const std::string &key)
279 {
280 GVariant *variant = getVariantAtKey (mSettings,
281 CharacterWrapper (translateKeyForGSettings (key.c_str ())),
282 CharacterWrapper (makeCompizPluginPath (profileName.c_str (), plugin.c_str ())),
283 TypeFloat);
284 return readFloatFromVariant (variant);
285 }
286
287 const char * ReadStringAtKey (const std::string &plugin,
288 const std::string &key)
289 {
290 GVariant *variant = getVariantAtKey (mSettings,
291 CharacterWrapper (translateKeyForGSettings (key.c_str ())),
292 CharacterWrapper (makeCompizPluginPath (profileName.c_str (), plugin.c_str ())),
293 TypeString);
294 return readStringFromVariant (variant);
295 }
296
297 CCSSettingColorValue ReadColorAtKey (const std::string &plugin,
298 const std::string &key)
299 {
300 Bool success = FALSE;
301 GVariant *variant = getVariantAtKey (mSettings,
302 CharacterWrapper (translateKeyForGSettings (key.c_str ())),
303 CharacterWrapper (makeCompizPluginPath (profileName.c_str (), plugin.c_str ())),
304 TypeColor);
305 CCSSettingColorValue value = readColorFromVariant (variant, &success);
306 EXPECT_TRUE (success);
307 return value;
308 }
309
310 CCSSettingKeyValue ReadKeyAtKey (const std::string &plugin,
311 const std::string &key)
312 {
313 Bool success = FALSE;
314 GVariant *variant = getVariantAtKey (mSettings,
315 CharacterWrapper (translateKeyForGSettings (key.c_str ())),
316 CharacterWrapper (makeCompizPluginPath (profileName.c_str (), plugin.c_str ())),
317 TypeKey);
318 CCSSettingKeyValue value = readKeyFromVariant (variant, &success);
319 EXPECT_TRUE (success);
320 return value;
321 }
322
323 CCSSettingButtonValue ReadButtonAtKey (const std::string &plugin,
324 const std::string &key)
325 {
326 Bool success = FALSE;
327 GVariant *variant = getVariantAtKey (mSettings,
328 CharacterWrapper (translateKeyForGSettings (key.c_str ())),
329 CharacterWrapper (makeCompizPluginPath (profileName.c_str (), plugin.c_str ())),
330 TypeButton);
331 CCSSettingButtonValue value = readButtonFromVariant (variant, &success);
332 EXPECT_TRUE (success);
333 return value;
334 }
335
336 unsigned int ReadEdgeAtKey (const std::string &plugin,
337 const std::string &key)
338 {
339 GVariant *variant = getVariantAtKey (mSettings,
340 CharacterWrapper (translateKeyForGSettings (key.c_str ())),
341 CharacterWrapper (makeCompizPluginPath (profileName.c_str (), plugin.c_str ())),
342 TypeEdge);
343 return readEdgeFromVariant (variant);
344 }
345
346 const char * ReadMatchAtKey (const std::string &plugin,
347 const std::string &key)
348 {
349 GVariant *variant = getVariantAtKey (mSettings,
350 CharacterWrapper (translateKeyForGSettings (key.c_str ())),
351 CharacterWrapper (makeCompizPluginPath (profileName.c_str (), plugin.c_str ())),
352 TypeMatch);
353 return readStringFromVariant (variant);
354 }
355
356 Bool ReadBellAtKey (const std::string &plugin,
357 const std::string &key)
358 {
359 GVariant *variant = getVariantAtKey (mSettings,
360 CharacterWrapper (translateKeyForGSettings (key.c_str ())),
361 CharacterWrapper (makeCompizPluginPath (profileName.c_str (), plugin.c_str ())),
362 TypeBell);
363 return readBoolFromVariant (variant);
364 }
365
366 CCSSettingValueList ReadListAtKey (const std::string &plugin,
367 const std::string &key,
368 CCSSettingInfo *info)
369 {
370 GVariant *variant = getVariantAtKey (mSettings,
371 CharacterWrapper (translateKeyForGSettings (key.c_str ())),
372 CharacterWrapper (makeCompizPluginPath (profileName.c_str (), plugin.c_str ())),
373 TypeList);
374 return readListValue (variant, info->forList.listType);
375 }
376
377 void PreUpdate (CCSContextGMock *gmockContext,
378 CCSPluginGMock *gmockPlugin,
379 CCSSettingGMock *gmockSetting,
380 CCSSettingType type)
381 {
382 EXPECT_CALL (*gmockContext, getIntegrationEnabled ()).WillOnce (Return (FALSE));
383 EXPECT_CALL (*gmockPlugin, getContext ()).Times (AtLeast (1));
384 EXPECT_CALL (*gmockPlugin, getName ()).Times (AtLeast (1));
385 EXPECT_CALL (*gmockSetting, getType ()).Times (AtLeast (1));
386 EXPECT_CALL (*gmockSetting, getName ()).Times (AtLeast (1));
387 EXPECT_CALL (*gmockSetting, getParent ()).Times (AtLeast (1));
388 EXPECT_CALL (*gmockSetting, isReadOnly ()).WillRepeatedly (Return (FALSE));
389
390 if (type == TypeList)
391 {
392 EXPECT_CALL (*gmockSetting, getInfo ()).Times (AtLeast (1));
393 EXPECT_CALL (*gmockSetting, getDefaultValue ()).WillRepeatedly (ReturnNull ());
394 }
395
396 EXPECT_CALL (*gmockContext, getProfile ());
397 }
398
399 void PostUpdate (CCSContextGMock *gmockContext,
400 CCSPluginGMock *gmockPlugin,
401 CCSSettingGMock *gmockSetting,
402 CCSSettingType type) {}
403
404 bool UpdateSettingAtKey (const std::string &plugin,
405 const std::string &setting)
406 {
407 CharacterWrapper keyName (translateKeyForGSettings (setting.c_str ()));
408
409 if (updateSettingWithGSettingsKeyName (reinterpret_cast <CCSBackend *> (mGSettingsBackend), mSettings, keyName, ccsBackendUpdateSetting))
410 return true;
411
412 return false;
413 }
414
415 private:
416
417 GSettings *mSettings;
418 CCSContext *mContext;
419 CCSBackendWithCapabilities *mBackend;
420 CCSBackend *mGSettingsBackend;
421 std::string pluginToMatch;
422 CCSGSettingsBackendInterface overloadedInterface;
423
424 static const std::string profileName;
425};
426
427const std::string CCSGSettingsBackendEnv::profileName = "mock";
428
429INSTANTIATE_TEST_CASE_P (CCSGSettingsBackendConcept, CCSBackendConformanceTestReadWrite,
430 compizconfig::test::GenerateTestingParametersForBackendInterface <CCSGSettingsBackendEnv> ());
431
0432
=== modified file 'compizconfig/gsettings/tests/test_gsettings_tests.cpp'
--- compizconfig/gsettings/tests/test_gsettings_tests.cpp 2012-07-21 20:44:19 +0000
+++ compizconfig/gsettings/tests/test_gsettings_tests.cpp 2012-07-21 20:44:20 +0000
@@ -909,7 +909,7 @@
909{909{
910 GVariant *v = g_variant_new ("i", 1);910 GVariant *v = g_variant_new ("i", 1);
911911
912 EXPECT_FALSE (checkReadVariantIsValid (v, TypeInt, "foo/bar"));912 EXPECT_TRUE (checkReadVariantIsValid (v, TypeInt, "foo/bar"));
913913
914 g_variant_unref (v);914 g_variant_unref (v);
915}915}
916916
=== modified file 'compizconfig/libcompizconfig/backend/src/ini.c'
--- compizconfig/libcompizconfig/backend/src/ini.c 2012-07-21 20:44:19 +0000
+++ compizconfig/libcompizconfig/backend/src/ini.c 2012-07-21 20:44:20 +0000
@@ -605,6 +605,16 @@
605 free (fileName);605 free (fileName);
606}606}
607607
608static void
609updateSetting (CCSBackend *backend, CCSContext *context, CCSPlugin *plugin, CCSSetting *setting)
610{
611 if (readInit (backend, context))
612 {
613 readSetting (backend, context, setting);
614 readDone (backend, context);
615 }
616}
617
608static Bool618static Bool
609getSettingIsReadOnly (CCSBackend *backend, CCSSetting * setting)619getSettingIsReadOnly (CCSBackend *backend, CCSSetting * setting)
610{620{
@@ -762,6 +772,7 @@
762 writeInit,772 writeInit,
763 writeSetting,773 writeSetting,
764 writeDone,774 writeDone,
775 updateSetting,
765 NULL,776 NULL,
766 getSettingIsReadOnly,777 getSettingIsReadOnly,
767 getExistingProfiles,778 getExistingProfiles,
768779
=== modified file 'compizconfig/libcompizconfig/include/ccs-backend.h'
--- compizconfig/libcompizconfig/include/ccs-backend.h 2012-07-21 20:44:19 +0000
+++ compizconfig/libcompizconfig/include/ccs-backend.h 2012-07-21 20:44:20 +0000
@@ -33,6 +33,7 @@
33typedef struct _CCSBackendInterface CCSBackendInterface;33typedef struct _CCSBackendInterface CCSBackendInterface;
3434
35typedef struct _CCSContext CCSContext;35typedef struct _CCSContext CCSContext;
36typedef struct _CCSPlugin CCSPlugin;
36typedef struct _CCSSetting CCSSetting;37typedef struct _CCSSetting CCSSetting;
3738
38struct _CCSBackend39struct _CCSBackend
@@ -57,6 +58,8 @@
57(CCSBackend *, CCSContext * context, CCSSetting * setting);58(CCSBackend *, CCSContext * context, CCSSetting * setting);
58typedef void (*CCSBackendWriteDoneFunc) (CCSBackend *, CCSContext * context);59typedef void (*CCSBackendWriteDoneFunc) (CCSBackend *, CCSContext * context);
5960
61typedef void (*CCSBackendUpdateFunc) (CCSBackend *, CCSContext *, CCSPlugin *, CCSSetting *);
62
60typedef Bool (*CCSBackendGetSettingIsIntegratedFunc) (CCSBackend *, CCSSetting * setting);63typedef Bool (*CCSBackendGetSettingIsIntegratedFunc) (CCSBackend *, CCSSetting * setting);
61typedef Bool (*CCSBackendGetSettingIsReadOnlyFunc) (CCSBackend *, CCSSetting * setting);64typedef Bool (*CCSBackendGetSettingIsReadOnlyFunc) (CCSBackend *, CCSSetting * setting);
6265
@@ -93,6 +96,7 @@
93 CCSBackendWriteSettingFunc writeSetting;96 CCSBackendWriteSettingFunc writeSetting;
94 CCSBackendWriteDoneFunc writeDone;97 CCSBackendWriteDoneFunc writeDone;
9598
99 CCSBackendUpdateFunc updateSetting;
96100
97 CCSBackendGetSettingIsIntegratedFunc getSettingIsIntegrated;101 CCSBackendGetSettingIsIntegratedFunc getSettingIsIntegrated;
98 CCSBackendGetSettingIsReadOnlyFunc getSettingIsReadOnly;102 CCSBackendGetSettingIsReadOnlyFunc getSettingIsReadOnly;
@@ -118,6 +122,7 @@
118Bool ccsBackendWriteInit (CCSBackend *backend, CCSContext *context);122Bool ccsBackendWriteInit (CCSBackend *backend, CCSContext *context);
119void ccsBackendWriteSetting (CCSBackend *backend, CCSContext *context, CCSSetting *setting);123void ccsBackendWriteSetting (CCSBackend *backend, CCSContext *context, CCSSetting *setting);
120void ccsBackendWriteDone (CCSBackend *backend, CCSContext *context);124void ccsBackendWriteDone (CCSBackend *backend, CCSContext *context);
125void ccsBackendUpdateSetting (CCSBackend *backend, CCSContext *context, CCSPlugin *plugin, CCSSetting *setting);
121Bool ccsBackendGetSettingIsIntegrated (CCSBackend *backend, CCSSetting *setting);126Bool ccsBackendGetSettingIsIntegrated (CCSBackend *backend, CCSSetting *setting);
122Bool ccsBackendGetSettingIsReadOnly (CCSBackend *backend, CCSSetting *setting);127Bool ccsBackendGetSettingIsReadOnly (CCSBackend *backend, CCSSetting *setting);
123CCSStringList ccsBackendGetExistingProfiles (CCSBackend *backend, CCSContext *context);128CCSStringList ccsBackendGetExistingProfiles (CCSBackend *backend, CCSContext *context);
@@ -157,12 +162,18 @@
157162
158/* Backend opener method */163/* Backend opener method */
159void *164void *
160ccsBackendOpen (char *name, CCSBackendInterface **interface, Bool *fellback);165ccsOpenBackend (const char *name, CCSBackendInterface **interface, Bool *fellback);
161166
162/* Constructor method */167/* Constructor method */
163CCSBackend *168CCSBackend *
164ccsBackendNewWithInterface (CCSContext *context, const CCSBackendInterface *interface, void *dlhand);169ccsBackendNewWithInterface (CCSContext *context, const CCSBackendInterface *interface, void *dlhand);
165170
171typedef struct _CCSInterfaceTable CCSInterfaceTable;
172
173/* Constructor method */
174CCSBackendWithCapabilities *
175ccsBackendWithCapabilitiesWrapBackend (const CCSInterfaceTable *interfaces, CCSBackend *backend);
176
166CCSBackendInterface* getBackendInfo (void);177CCSBackendInterface* getBackendInfo (void);
167178
168COMPIZCONFIG_END_DECLS179COMPIZCONFIG_END_DECLS
169180
=== modified file 'compizconfig/libcompizconfig/include/ccs.h'
--- compizconfig/libcompizconfig/include/ccs.h 2012-07-21 20:44:19 +0000
+++ compizconfig/libcompizconfig/include/ccs.h 2012-07-21 20:44:20 +0000
@@ -808,6 +808,10 @@
808CCSSettingColorValue* ccsGetColorArrayFromValueList (CCSSettingValueList list,808CCSSettingColorValue* ccsGetColorArrayFromValueList (CCSSettingValueList list,
809 int *num);809 int *num);
810810
811/* Copies lists */
812CCSSettingValueList
813ccsCopyList (CCSSettingValueList l1, CCSSetting * setting);
814
811/* Converts an array of data items to a setting value list. Behaves similar815/* Converts an array of data items to a setting value list. Behaves similar
812 to ccsGetListFromStringArray */816 to ccsGetListFromStringArray */
813CCSSettingValueList ccsGetValueListFromStringArray (const char **array,817CCSSettingValueList ccsGetValueListFromStringArray (const char **array,
814818
=== modified file 'compizconfig/libcompizconfig/src/main.c'
--- compizconfig/libcompizconfig/src/main.c 2012-07-21 20:44:19 +0000
+++ compizconfig/libcompizconfig/src/main.c 2012-07-21 20:44:20 +0000
@@ -1014,7 +1014,7 @@
1014CCSREF_OBJ (BackendWithCapabilities, CCSBackendWithCapabilities)1014CCSREF_OBJ (BackendWithCapabilities, CCSBackendWithCapabilities)
10151015
1016static void *1016static void *
1017openBackend (char *backend)1017openBackend (const char *backend)
1018{1018{
1019 char *home = getenv ("HOME");1019 char *home = getenv ("HOME");
1020 char *override_backend = getenv ("LIBCOMPIZCONFIG_BACKEND_PATH");1020 char *override_backend = getenv ("LIBCOMPIZCONFIG_BACKEND_PATH");
@@ -1158,7 +1158,7 @@
1158}1158}
11591159
1160void *1160void *
1161ccsOpenBackend (char *name, CCSBackendInterface **vt, Bool *fellback)1161ccsOpenBackend (const char *name, CCSBackendInterface **vt, Bool *fellback)
1162{1162{
1163 void *dlhand = openBackend (name);1163 void *dlhand = openBackend (name);
1164 if (!dlhand)1164 if (!dlhand)
@@ -1378,11 +1378,21 @@
1378 return (GET_INTERFACE (CCSBackendInterface, backend))->writeDone != NULL;1378 return (GET_INTERFACE (CCSBackendInterface, backend))->writeDone != NULL;
1379}1379}
13801380
1381static Bool ccsBackendHasUpdateSetting (CCSBackend *backend)
1382{
1383 return (GET_INTERFACE (CCSBackendInterface, backend))->updateSetting != NULL;
1384}
1385
1381void ccsBackendWriteDone (CCSBackend *backend, CCSContext *context)1386void ccsBackendWriteDone (CCSBackend *backend, CCSContext *context)
1382{1387{
1383 return (*(GET_INTERFACE (CCSBackendInterface, backend))->writeDone) (backend, context);1388 return (*(GET_INTERFACE (CCSBackendInterface, backend))->writeDone) (backend, context);
1384}1389}
13851390
1391void ccsBackendUpdateSetting (CCSBackend *backend, CCSContext *context, CCSPlugin *plugin, CCSSetting *setting)
1392{
1393 return (*(GET_INTERFACE (CCSBackendInterface, backend))->updateSetting) (backend, context, plugin, setting);
1394}
1395
1386static Bool ccsBackendHasGetSettingIsIntegrated (CCSBackend *backend)1396static Bool ccsBackendHasGetSettingIsIntegrated (CCSBackend *backend)
1387{1397{
1388 return (GET_INTERFACE (CCSBackendInterface, backend))->getSettingIsIntegrated != NULL;1398 return (GET_INTERFACE (CCSBackendInterface, backend))->getSettingIsIntegrated != NULL;
@@ -1556,6 +1566,14 @@
1556 ccsBackendWriteDone (bcPrivate->backend, context);1566 ccsBackendWriteDone (bcPrivate->backend, context);
1557}1567}
15581568
1569static void ccsBackendCapabilitiesUpdateSettingWrapper (CCSBackend *backend, CCSContext *context, CCSPlugin *plugin, CCSSetting *setting)
1570{
1571 CAPABILITIES_PRIV (backend);
1572
1573 if (ccsBackendHasUpdateSetting (bcPrivate->backend))
1574 ccsBackendUpdateSetting (bcPrivate->backend, context, plugin, setting);
1575}
1576
1559static Bool ccsBackendCapabilitiesGetSettingIsIntegratedWrapper (CCSBackend *backend, CCSSetting *setting)1577static Bool ccsBackendCapabilitiesGetSettingIsIntegratedWrapper (CCSBackend *backend, CCSSetting *setting)
1560{1578{
1561 CAPABILITIES_PRIV (backend);1579 CAPABILITIES_PRIV (backend);
@@ -1614,8 +1632,14 @@
1614 return FALSE;1632 return FALSE;
1615 break;1633 break;
1616 case TypeBool:1634 case TypeBool:
1617 if (l1->data->value.asBool != l2->data->value.asBool)1635 {
1618 return FALSE;1636 Bool bothTrue = (l1->data->value.asBool && l2->data->value.asBool);
1637 Bool bothFalse = (!l1->data->value.asBool && !l2->data->value.asBool);
1638
1639 /* Use the boolean operators as TRUE/FALSE can be redefined */
1640 if (!bothTrue && !bothFalse)
1641 return FALSE;
1642 }
1619 break;1643 break;
1620 case TypeFloat:1644 case TypeFloat:
1621 if (l1->data->value.asFloat != l2->data->value.asFloat)1645 if (l1->data->value.asFloat != l2->data->value.asFloat)
@@ -2300,13 +2324,11 @@
2300 return TRUE;2324 return TRUE;
2301}2325}
23022326
2303static CCSSettingValueList2327CCSSettingValueList
2304ccsCopyList (CCSSettingValueList l1, CCSSetting * setting)2328ccsCopyList (CCSSettingValueList l1, CCSSetting * setting)
2305{2329{
2306 CCSSettingValueList l2 = NULL;2330 CCSSettingValueList l2 = NULL;
23072331
2308 SETTING_PRIV (setting)
2309
2310 while (l1)2332 while (l1)
2311 {2333 {
2312 CCSSettingValue *value = calloc (1, sizeof (CCSSettingValue));2334 CCSSettingValue *value = calloc (1, sizeof (CCSSettingValue));
@@ -2317,7 +2339,7 @@
2317 value->parent = setting;2339 value->parent = setting;
2318 value->isListChild = TRUE;2340 value->isListChild = TRUE;
23192341
2320 switch (sPrivate->info.forList.listType)2342 switch (ccsSettingGetInfo (setting)->forList.listType)
2321 {2343 {
2322 case TypeInt:2344 case TypeInt:
2323 value->value.asInt = l1->data->value.asInt;2345 value->value.asInt = l1->data->value.asInt;
@@ -5520,6 +5542,7 @@
5520 ccsBackendCapabilitiesWriteInitWrapper,5542 ccsBackendCapabilitiesWriteInitWrapper,
5521 ccsBackendCapabilitiesWriteSettingWrapper,5543 ccsBackendCapabilitiesWriteSettingWrapper,
5522 ccsBackendCapabilitiesWriteDoneWrapper,5544 ccsBackendCapabilitiesWriteDoneWrapper,
5545 ccsBackendCapabilitiesUpdateSettingWrapper,
5523 ccsBackendCapabilitiesGetSettingIsIntegratedWrapper,5546 ccsBackendCapabilitiesGetSettingIsIntegratedWrapper,
5524 ccsBackendCapabilitiesGetSettingIsReadOnlyWrapper,5547 ccsBackendCapabilitiesGetSettingIsReadOnlyWrapper,
5525 ccsBackendCapabilitiesGetExistingProfilesWrapper,5548 ccsBackendCapabilitiesGetExistingProfilesWrapper,
55265549
=== modified file 'compizconfig/libcompizconfig/tests/compizconfig_test_ccs_mock_backend_conformance.cpp'
--- compizconfig/libcompizconfig/tests/compizconfig_test_ccs_mock_backend_conformance.cpp 2012-07-21 20:44:19 +0000
+++ compizconfig/libcompizconfig/tests/compizconfig_test_ccs_mock_backend_conformance.cpp 2012-07-21 20:44:20 +0000
@@ -15,6 +15,7 @@
15using ::testing::Combine;15using ::testing::Combine;
16using ::testing::ValuesIn;16using ::testing::ValuesIn;
17using ::testing::Values;17using ::testing::Values;
18using ::testing::AtLeast;
1819
19namespace20namespace
20{21{
@@ -49,6 +50,7 @@
4950
50 CCSBackend * SetUp (CCSContext *context, CCSContextGMock *gmockContext)51 CCSBackend * SetUp (CCSContext *context, CCSContextGMock *gmockContext)
51 {52 {
53 mContext = context;
52 mBackend = ccsMockBackendNew ();54 mBackend = ccsMockBackendNew ();
53 mBackendGMock = (CCSBackendGMock *) ccsObjectGetPrivate (mBackend);55 mBackendGMock = (CCSBackendGMock *) ccsObjectGetPrivate (mBackend);
5456
@@ -59,6 +61,13 @@
59 this,61 this,
60 &MockCCSBackendConceptTestEnvironment::ReadValueIntoSetting)));62 &MockCCSBackendConceptTestEnvironment::ReadValueIntoSetting)));
6163
64 ON_CALL (*mBackendGMock, updateSetting (_, _, _))
65 .WillByDefault (
66 WithArgs<2> (
67 Invoke (
68 this,
69 &MockCCSBackendConceptTestEnvironment::ReadValueIntoSetting)));
70
62 ON_CALL (*mBackendGMock, writeSetting (_, _))71 ON_CALL (*mBackendGMock, writeSetting (_, _))
63 .WillByDefault (72 .WillByDefault (
64 WithArgs<1> (73 WithArgs<1> (
@@ -72,7 +81,6 @@
72 void TearDown (CCSBackend *backend)81 void TearDown (CCSBackend *backend)
73 {82 {
74 ccsFreeMockBackend (backend);83 ccsFreeMockBackend (backend);
75
76 }84 }
7785
78 void PreWrite (CCSContextGMock *gmockContext,86 void PreWrite (CCSContextGMock *gmockContext,
@@ -83,8 +91,17 @@
83 EXPECT_CALL (*mBackendGMock, writeSetting (_, _));91 EXPECT_CALL (*mBackendGMock, writeSetting (_, _));
84 EXPECT_CALL (*gmockPlugin, getName ());92 EXPECT_CALL (*gmockPlugin, getName ());
85 EXPECT_CALL (*gmockSetting, getName ());93 EXPECT_CALL (*gmockSetting, getName ());
86 EXPECT_CALL (*gmockSetting, getType ());
87 EXPECT_CALL (*gmockSetting, getParent ());94 EXPECT_CALL (*gmockSetting, getParent ());
95
96 if (type == TypeList)
97 {
98 EXPECT_CALL (*gmockSetting, getType ()).Times (AtLeast (1));
99 EXPECT_CALL (*gmockSetting, getDefaultValue ()).Times (AtLeast (1));
100 }
101 else
102 {
103 EXPECT_CALL (*gmockSetting, getType ());
104 }
88 }105 }
89106
90 void PostWrite (CCSContextGMock *gmockContext,107 void PostWrite (CCSContextGMock *gmockContext,
@@ -180,8 +197,17 @@
180 EXPECT_CALL (*mBackendGMock, readSetting (_, _));197 EXPECT_CALL (*mBackendGMock, readSetting (_, _));
181 EXPECT_CALL (*gmockPlugin, getName ());198 EXPECT_CALL (*gmockPlugin, getName ());
182 EXPECT_CALL (*gmockSetting, getName ());199 EXPECT_CALL (*gmockSetting, getName ());
183 EXPECT_CALL (*gmockSetting, getType ());
184 EXPECT_CALL (*gmockSetting, getParent ());200 EXPECT_CALL (*gmockSetting, getParent ());
201
202 if (type == TypeList)
203 {
204 EXPECT_CALL (*gmockSetting, getType ()).Times (AtLeast (1));
205 EXPECT_CALL (*gmockSetting, getInfo ()).Times (AtLeast (1));
206 }
207 else
208 {
209 EXPECT_CALL (*gmockSetting, getType ());
210 }
185 }211 }
186212
187 void PostRead (CCSContextGMock *gmockContext,213 void PostRead (CCSContextGMock *gmockContext,
@@ -252,11 +278,57 @@
252 }278 }
253279
254 virtual CCSSettingValueList ReadListAtKey (const std::string &plugin,280 virtual CCSSettingValueList ReadListAtKey (const std::string &plugin,
255 const std::string &key)281 const std::string &key,
282 CCSSettingInfo *info)
256 {283 {
257 return *(ValueForKeyRetreival <boost::shared_ptr <CCSListWrapper> > ().GetValueForKey (keynameFromPluginKey (plugin, key), mValues));284 return *(ValueForKeyRetreival <boost::shared_ptr <CCSListWrapper> > ().GetValueForKey (keynameFromPluginKey (plugin, key), mValues));
258 }285 }
259286
287 void PreUpdate (CCSContextGMock *gmockContext,
288 CCSPluginGMock *gmockPlugin,
289 CCSSettingGMock *gmockSetting,
290 CCSSettingType type)
291 {
292 EXPECT_CALL (*mBackendGMock, updateSetting (_, _, _));
293 EXPECT_CALL (*gmockPlugin, getName ());
294 EXPECT_CALL (*gmockSetting, getName ());
295 EXPECT_CALL (*gmockSetting, getParent ());
296
297 if (type == TypeList)
298 {
299 EXPECT_CALL (*gmockSetting, getType ()).Times (AtLeast (1));
300 EXPECT_CALL (*gmockSetting, getInfo ()).Times (AtLeast (1));
301 }
302 else
303 {
304 EXPECT_CALL (*gmockSetting, getType ());
305 }
306 }
307
308 void PostUpdate (CCSContextGMock *gmockContext,
309 CCSPluginGMock *gmockPlugin,
310 CCSSettingGMock *gmockSetting,
311 CCSSettingType type)
312 {
313 }
314
315 bool UpdateSettingAtKey (const std::string &plugin,
316 const std::string &setting)
317 {
318 CCSPlugin *cplugin = ccsFindPlugin (mContext, plugin.c_str ());
319
320 if (!cplugin)
321 return false;
322
323 CCSSetting *csetting = ccsFindSetting (cplugin, setting.c_str ());
324
325 if (!csetting)
326 return false;
327
328 ccsBackendUpdateSetting (mBackend, mContext, cplugin, csetting);
329 return true;
330 }
331
260 protected:332 protected:
261333
262 void ReadValueIntoSetting (CCSSetting *setting)334 void ReadValueIntoSetting (CCSSetting *setting)
@@ -317,9 +389,12 @@
317 break;389 break;
318390
319 case TypeList:391 case TypeList:
392 {
393 CCSSettingInfo *info = ccsSettingGetInfo (setting);
320394
321 ccsSetList (setting, ReadListAtKey (plugin, key), FALSE);395 ccsSetList (setting, ReadListAtKey (plugin, key, info), FALSE);
322 break;396 }
397 break;
323398
324 default:399 default:
325400
@@ -405,11 +480,18 @@
405 break;480 break;
406481
407 case TypeList:482 case TypeList:
483 {
484 CCSSettingValueList listCopy = NULL;
408485
409 ccsGetList (setting, &vList);486 ccsGetList (setting, &vList);
410 WriteListAtKey (plugin, key, VariantTypes (boost::make_shared <CCSListWrapper> (vList, false, ccsSettingGetInfo (setting)->forList.listType)));487 listCopy = ccsCopyList (vList, setting);
488
489 WriteListAtKey (plugin, key, VariantTypes (boost::make_shared <CCSListWrapper> (listCopy, true,
490 ccsSettingGetInfo (setting)->forList.listType,
491 boost::shared_ptr <CCSSettingInfo> (),
492 boost::shared_ptr <CCSSetting> ())));
411 break;493 break;
412494 }
413 default:495 default:
414496
415 throw std::exception ();497 throw std::exception ();
@@ -420,6 +502,7 @@
420502
421 CCSBackend *mBackend;503 CCSBackend *mBackend;
422 CCSBackendGMock *mBackendGMock;504 CCSBackendGMock *mBackendGMock;
505 CCSContext *mContext;
423 std::map <std::string, VariantTypes> mValues;506 std::map <std::string, VariantTypes> mValues;
424};507};
425508
426509
=== modified file 'compizconfig/mocks/libcompizconfig/compizconfig_ccs_backend_mock.cpp'
--- compizconfig/mocks/libcompizconfig/compizconfig_ccs_backend_mock.cpp 2012-07-21 20:44:19 +0000
+++ compizconfig/mocks/libcompizconfig/compizconfig_ccs_backend_mock.cpp 2012-07-21 20:44:20 +0000
@@ -21,6 +21,7 @@
21 CCSBackendGMock::ccsBackendWriteInit,21 CCSBackendGMock::ccsBackendWriteInit,
22 CCSBackendGMock::ccsBackendWriteSetting,22 CCSBackendGMock::ccsBackendWriteSetting,
23 CCSBackendGMock::ccsBackendWriteDone,23 CCSBackendGMock::ccsBackendWriteDone,
24 CCSBackendGMock::ccsBackendUpdateSetting,
24 CCSBackendGMock::ccsBackendGetSettingIsIntegrated,25 CCSBackendGMock::ccsBackendGetSettingIsIntegrated,
25 CCSBackendGMock::ccsBackendGetSettingIsReadOnly,26 CCSBackendGMock::ccsBackendGetSettingIsReadOnly,
26 CCSBackendGMock::ccsBackendGetExistingProfiles,27 CCSBackendGMock::ccsBackendGetExistingProfiles,
2728
=== modified file 'compizconfig/mocks/libcompizconfig/compizconfig_ccs_backend_mock.h'
--- compizconfig/mocks/libcompizconfig/compizconfig_ccs_backend_mock.h 2012-07-21 20:44:19 +0000
+++ compizconfig/mocks/libcompizconfig/compizconfig_ccs_backend_mock.h 2012-07-21 20:44:20 +0000
@@ -29,6 +29,7 @@
29 virtual Bool writeInit (CCSContext *conxtext) = 0;29 virtual Bool writeInit (CCSContext *conxtext) = 0;
30 virtual void writeSetting (CCSContext *context, CCSSetting *setting) = 0;30 virtual void writeSetting (CCSContext *context, CCSSetting *setting) = 0;
31 virtual void writeDone (CCSContext *context) = 0;31 virtual void writeDone (CCSContext *context) = 0;
32 virtual void updateSetting (CCSContext *context, CCSPlugin *plugin, CCSSetting *setting) = 0;
32 virtual Bool getSettingIsIntegrated (CCSSetting *setting) = 0;33 virtual Bool getSettingIsIntegrated (CCSSetting *setting) = 0;
33 virtual Bool getSettingIsReadOnly (CCSSetting *setting) = 0;34 virtual Bool getSettingIsReadOnly (CCSSetting *setting) = 0;
34 virtual CCSStringList getExistingProfiles (CCSContext *context) = 0;35 virtual CCSStringList getExistingProfiles (CCSContext *context) = 0;
@@ -62,6 +63,7 @@
62 MOCK_METHOD1 (writeInit, Bool (CCSContext *));63 MOCK_METHOD1 (writeInit, Bool (CCSContext *));
63 MOCK_METHOD2 (writeSetting, void (CCSContext *, CCSSetting *));64 MOCK_METHOD2 (writeSetting, void (CCSContext *, CCSSetting *));
64 MOCK_METHOD1 (writeDone, void (CCSContext *));65 MOCK_METHOD1 (writeDone, void (CCSContext *));
66 MOCK_METHOD3 (updateSetting, void (CCSContext *, CCSPlugin *, CCSSetting *));
65 MOCK_METHOD1 (getSettingIsIntegrated, Bool (CCSSetting *));67 MOCK_METHOD1 (getSettingIsIntegrated, Bool (CCSSetting *));
66 MOCK_METHOD1 (getSettingIsReadOnly, Bool (CCSSetting *));68 MOCK_METHOD1 (getSettingIsReadOnly, Bool (CCSSetting *));
67 MOCK_METHOD1 (getExistingProfiles, CCSStringList (CCSContext *));69 MOCK_METHOD1 (getExistingProfiles, CCSStringList (CCSContext *));
@@ -144,6 +146,11 @@
144 ((CCSBackendGMock *) ccsObjectGetPrivate (backend))->writeDone (context);146 ((CCSBackendGMock *) ccsObjectGetPrivate (backend))->writeDone (context);
145 }147 }
146148
149 static void ccsBackendUpdateSetting (CCSBackend *backend, CCSContext *context, CCSPlugin *plugin, CCSSetting *setting)
150 {
151 ((CCSBackendGMock *) ccsObjectGetPrivate (backend))->updateSetting (context, plugin, setting);
152 }
153
147 static Bool ccsBackendGetSettingIsIntegrated (CCSBackend *backend, CCSSetting *setting)154 static Bool ccsBackendGetSettingIsIntegrated (CCSBackend *backend, CCSSetting *setting)
148 {155 {
149 return ((CCSBackendGMock *) ccsObjectGetPrivate (backend))->getSettingIsIntegrated (setting);156 return ((CCSBackendGMock *) ccsObjectGetPrivate (backend))->getSettingIsIntegrated (setting);
150157
=== modified file 'compizconfig/tests/compizconfig_backend_concept_test.h'
--- compizconfig/tests/compizconfig_backend_concept_test.h 2012-07-21 20:44:19 +0000
+++ compizconfig/tests/compizconfig_backend_concept_test.h 2012-07-21 20:44:20 +0000
@@ -13,6 +13,8 @@
13#include <gtest/gtest.h>13#include <gtest/gtest.h>
14#include <gmock/gmock.h>14#include <gmock/gmock.h>
1515
16#include <X11/keysym.h>
17
16#include <ccs-backend.h>18#include <ccs-backend.h>
17#include <ccs.h>19#include <ccs.h>
1820
@@ -24,10 +26,15 @@
24using ::testing::SetArgPointee;26using ::testing::SetArgPointee;
25using ::testing::DoAll;27using ::testing::DoAll;
26using ::testing::Return;28using ::testing::Return;
29using ::testing::ReturnNull;
27using ::testing::MakeMatcher;30using ::testing::MakeMatcher;
28using ::testing::Matcher;31using ::testing::Matcher;
29using ::testing::MatcherInterface;32using ::testing::MatcherInterface;
30using ::testing::MatchResultListener;33using ::testing::MatchResultListener;
34using ::testing::AtLeast;
35
36MATCHER(IsTrue, "Is True") { if (arg) return true; else return false; }
37MATCHER(IsFalse, "Is False") { if (!arg) return true; else return false; }
3138
32class ListEqualityMatcher :39class ListEqualityMatcher :
33 public MatcherInterface <CCSSettingValueList>40 public MatcherInterface <CCSSettingValueList>
@@ -77,6 +84,13 @@
77 return false;84 return false;
78}85}
7986
87::std::ostream &
88operator<< (::std::ostream &os, const CCSSettingColorValue &v)
89{
90 return os << "Red: " << std::hex << v.color.red << "Blue: " << std::hex << v.color.blue << "Green: " << v.color.green << "Alpha: " << v.color.alpha
91 << std::dec << std::endl;
92}
93
80bool94bool
81operator== (const CCSSettingKeyValue &lhs,95operator== (const CCSSettingKeyValue &lhs,
82 const CCSSettingKeyValue &rhs)96 const CCSSettingKeyValue &rhs)
@@ -86,6 +100,12 @@
86 return false;100 return false;
87}101}
88102
103::std::ostream &
104operator<< (::std::ostream &os, const CCSSettingKeyValue &v)
105{
106 return os << "Keysym: " << v.keysym << " KeyModMask " << std::hex << v.keyModMask << std::dec << std::endl;
107}
108
89bool109bool
90operator== (const CCSSettingButtonValue &lhs,110operator== (const CCSSettingButtonValue &lhs,
91 const CCSSettingButtonValue &rhs)111 const CCSSettingButtonValue &rhs)
@@ -95,6 +115,42 @@
95 return false;115 return false;
96}116}
97117
118::std::ostream &
119operator<< (::std::ostream &os, const CCSSettingButtonValue &v)
120{
121 return os << "Button " << v.button << "Button Key Mask: " << std::hex << v.buttonModMask << "Edge Mask: " << v.edgeMask << std::dec << std::endl;
122}
123
124class CharacterWrapper :
125 boost::noncopyable
126{
127 public:
128
129 explicit CharacterWrapper (char *c) :
130 mChar (c)
131 {
132 }
133
134 ~CharacterWrapper ()
135 {
136 free (mChar);
137 }
138
139 operator char * ()
140 {
141 return mChar;
142 }
143
144 operator const char * () const
145 {
146 return mChar;
147 }
148
149 private:
150
151 char *mChar;
152};
153
98class CCSListWrapper :154class CCSListWrapper :
99 boost::noncopyable155 boost::noncopyable
100{156{
@@ -102,10 +158,16 @@
102158
103 typedef boost::shared_ptr <CCSListWrapper> Ptr;159 typedef boost::shared_ptr <CCSListWrapper> Ptr;
104160
105 CCSListWrapper (CCSSettingValueList list, bool freeItems, CCSSettingType type) :161 CCSListWrapper (CCSSettingValueList list,
162 bool freeItems,
163 CCSSettingType type,
164 const boost::shared_ptr <CCSSettingInfo> &listInfo,
165 const boost::shared_ptr <CCSSetting> &settingReference) :
106 mList (list),166 mList (list),
107 mFreeItems (freeItems),167 mFreeItems (freeItems),
108 mType (type)168 mType (type),
169 mListInfo (listInfo),
170 mSettingReference (settingReference)
109 {171 {
110 }172 }
111173
@@ -130,6 +192,8 @@
130 CCSSettingValueList mList;192 CCSSettingValueList mList;
131 bool mFreeItems;193 bool mFreeItems;
132 CCSSettingType mType;194 CCSSettingType mType;
195 boost::shared_ptr <CCSSettingInfo> mListInfo;
196 boost::shared_ptr <CCSSetting> mSettingReference;
133};197};
134198
135typedef boost::variant <bool,199typedef boost::variant <bool,
@@ -146,6 +210,8 @@
146{210{
147 public:211 public:
148212
213 typedef boost::shared_ptr <CCSBackendConceptTestEnvironmentInterface> Ptr;
214
149 virtual ~CCSBackendConceptTestEnvironmentInterface () {};215 virtual ~CCSBackendConceptTestEnvironmentInterface () {};
150 virtual CCSBackend * SetUp (CCSContext *context,216 virtual CCSBackend * SetUp (CCSContext *context,
151 CCSContextGMock *gmockContext) = 0;217 CCSContextGMock *gmockContext) = 0;
@@ -224,7 +290,42 @@
224 virtual Bool ReadBellAtKey (const std::string &plugin,290 virtual Bool ReadBellAtKey (const std::string &plugin,
225 const std::string &key) = 0;291 const std::string &key) = 0;
226 virtual CCSSettingValueList ReadListAtKey (const std::string &plugin,292 virtual CCSSettingValueList ReadListAtKey (const std::string &plugin,
227 const std::string &key) = 0;293 const std::string &key,
294 CCSSettingInfo *info) = 0;
295
296 virtual void PreUpdate (CCSContextGMock *,
297 CCSPluginGMock *,
298 CCSSettingGMock *,
299 CCSSettingType) = 0;
300 virtual void PostUpdate (CCSContextGMock *,
301 CCSPluginGMock *,
302 CCSSettingGMock *,
303 CCSSettingType) = 0;
304
305 virtual bool UpdateSettingAtKey (const std::string &plugin,
306 const std::string &setting) = 0;
307};
308
309class CCSBackendConceptTestEnvironmentFactoryInterface
310{
311 public:
312
313 virtual ~CCSBackendConceptTestEnvironmentFactoryInterface () {}
314
315 virtual CCSBackendConceptTestEnvironmentInterface::Ptr ConstructTestEnv () = 0;
316};
317
318template <typename I>
319class CCSBackendConceptTestEnvironmentFactory :
320 public CCSBackendConceptTestEnvironmentFactoryInterface
321{
322 public:
323
324 CCSBackendConceptTestEnvironmentInterface::Ptr
325 ConstructTestEnv ()
326 {
327 return boost::shared_static_cast <I> (boost::make_shared <I> ());
328 }
228};329};
229330
230namespace331namespace
@@ -241,7 +342,7 @@
241 const VariantTypes &value,342 const VariantTypes &value,
242 CCSSetting *setting,343 CCSSetting *setting,
243 const WriteFunc &write,344 const WriteFunc &write,
244 CCSBackendConceptTestEnvironmentInterface *env)345 const CCSBackendConceptTestEnvironmentInterface::Ptr &env)
245{346{
246 CCSSettingGMock *gmock (getSettingGMockFromSetting (setting));347 CCSSettingGMock *gmock (getSettingGMockFromSetting (setting));
247 EXPECT_CALL (*gmock, getInt (_)).WillRepeatedly (DoAll (348 EXPECT_CALL (*gmock, getInt (_)).WillRepeatedly (DoAll (
@@ -257,7 +358,7 @@
257 const VariantTypes &value,358 const VariantTypes &value,
258 CCSSetting *setting,359 CCSSetting *setting,
259 const WriteFunc &write,360 const WriteFunc &write,
260 CCSBackendConceptTestEnvironmentInterface *env)361 const CCSBackendConceptTestEnvironmentInterface::Ptr &env)
261{362{
262 CCSSettingGMock *gmock (getSettingGMockFromSetting (setting));363 CCSSettingGMock *gmock (getSettingGMockFromSetting (setting));
263 EXPECT_CALL (*gmock, getBool (_)).WillRepeatedly (DoAll (364 EXPECT_CALL (*gmock, getBool (_)).WillRepeatedly (DoAll (
@@ -265,7 +366,13 @@
265 boolToBool (boost::get <bool> (value))),366 boolToBool (boost::get <bool> (value))),
266 Return (TRUE)));367 Return (TRUE)));
267 write ();368 write ();
268 EXPECT_EQ (env->ReadBoolAtKey (plugin, key), boolToBool (boost::get <bool> (value)));369
370 bool v (boost::get <bool> (value));
371
372 if (v)
373 EXPECT_THAT (env->ReadBoolAtKey (plugin, key), IsTrue ());
374 else
375 EXPECT_THAT (env->ReadBoolAtKey (plugin, key), IsFalse ());
269}376}
270377
271void SetFloatWriteExpectation (const std::string &plugin,378void SetFloatWriteExpectation (const std::string &plugin,
@@ -273,7 +380,7 @@
273 const VariantTypes &value,380 const VariantTypes &value,
274 CCSSetting *setting,381 CCSSetting *setting,
275 const WriteFunc &write,382 const WriteFunc &write,
276 CCSBackendConceptTestEnvironmentInterface *env)383 const CCSBackendConceptTestEnvironmentInterface::Ptr &env)
277{384{
278 CCSSettingGMock *gmock (getSettingGMockFromSetting (setting));385 CCSSettingGMock *gmock (getSettingGMockFromSetting (setting));
279 EXPECT_CALL (*gmock, getFloat (_)).WillRepeatedly (DoAll (386 EXPECT_CALL (*gmock, getFloat (_)).WillRepeatedly (DoAll (
@@ -289,7 +396,7 @@
289 const VariantTypes &value,396 const VariantTypes &value,
290 CCSSetting *setting,397 CCSSetting *setting,
291 const WriteFunc &write,398 const WriteFunc &write,
292 CCSBackendConceptTestEnvironmentInterface *env)399 const CCSBackendConceptTestEnvironmentInterface::Ptr &env)
293{400{
294 CCSSettingGMock *gmock (getSettingGMockFromSetting (setting));401 CCSSettingGMock *gmock (getSettingGMockFromSetting (setting));
295 EXPECT_CALL (*gmock, getString (_)).WillRepeatedly (DoAll (402 EXPECT_CALL (*gmock, getString (_)).WillRepeatedly (DoAll (
@@ -297,7 +404,7 @@
297 const_cast <char *> (boost::get <const char *> (value))),404 const_cast <char *> (boost::get <const char *> (value))),
298 Return (TRUE)));405 Return (TRUE)));
299 write ();406 write ();
300 EXPECT_EQ (env->ReadStringAtKey (plugin, key), boost::get <const char *> (value));407 EXPECT_EQ (std::string (env->ReadStringAtKey (plugin, key)), std::string (boost::get <const char *> (value)));
301}408}
302409
303void SetColorWriteExpectation (const std::string &plugin,410void SetColorWriteExpectation (const std::string &plugin,
@@ -305,7 +412,7 @@
305 const VariantTypes &value,412 const VariantTypes &value,
306 CCSSetting *setting,413 CCSSetting *setting,
307 const WriteFunc &write,414 const WriteFunc &write,
308 CCSBackendConceptTestEnvironmentInterface *env)415 const CCSBackendConceptTestEnvironmentInterface::Ptr &env)
309{416{
310 CCSSettingGMock *gmock (getSettingGMockFromSetting (setting));417 CCSSettingGMock *gmock (getSettingGMockFromSetting (setting));
311 EXPECT_CALL (*gmock, getColor (_)).WillRepeatedly (DoAll (418 EXPECT_CALL (*gmock, getColor (_)).WillRepeatedly (DoAll (
@@ -313,6 +420,7 @@
313 boost::get <CCSSettingColorValue> (value)),420 boost::get <CCSSettingColorValue> (value)),
314 Return (TRUE)));421 Return (TRUE)));
315 write ();422 write ();
423
316 EXPECT_EQ (env->ReadColorAtKey (plugin, key), boost::get <CCSSettingColorValue> (value));424 EXPECT_EQ (env->ReadColorAtKey (plugin, key), boost::get <CCSSettingColorValue> (value));
317}425}
318426
@@ -321,7 +429,7 @@
321 const VariantTypes &value,429 const VariantTypes &value,
322 CCSSetting *setting,430 CCSSetting *setting,
323 const WriteFunc &write,431 const WriteFunc &write,
324 CCSBackendConceptTestEnvironmentInterface *env)432 const CCSBackendConceptTestEnvironmentInterface::Ptr &env)
325{433{
326 CCSSettingGMock *gmock (getSettingGMockFromSetting (setting));434 CCSSettingGMock *gmock (getSettingGMockFromSetting (setting));
327 EXPECT_CALL (*gmock, getKey (_)).WillRepeatedly (DoAll (435 EXPECT_CALL (*gmock, getKey (_)).WillRepeatedly (DoAll (
@@ -337,7 +445,7 @@
337 const VariantTypes &value,445 const VariantTypes &value,
338 CCSSetting *setting,446 CCSSetting *setting,
339 const WriteFunc &write,447 const WriteFunc &write,
340 CCSBackendConceptTestEnvironmentInterface *env)448 const CCSBackendConceptTestEnvironmentInterface::Ptr &env)
341{449{
342 CCSSettingGMock *gmock (getSettingGMockFromSetting (setting));450 CCSSettingGMock *gmock (getSettingGMockFromSetting (setting));
343 EXPECT_CALL (*gmock, getButton (_)).WillRepeatedly (DoAll (451 EXPECT_CALL (*gmock, getButton (_)).WillRepeatedly (DoAll (
@@ -353,7 +461,7 @@
353 const VariantTypes &value,461 const VariantTypes &value,
354 CCSSetting *setting,462 CCSSetting *setting,
355 const WriteFunc &write,463 const WriteFunc &write,
356 CCSBackendConceptTestEnvironmentInterface *env)464 const CCSBackendConceptTestEnvironmentInterface::Ptr &env)
357{465{
358 CCSSettingGMock *gmock (getSettingGMockFromSetting (setting));466 CCSSettingGMock *gmock (getSettingGMockFromSetting (setting));
359 EXPECT_CALL (*gmock, getEdge (_)).WillRepeatedly (DoAll (467 EXPECT_CALL (*gmock, getEdge (_)).WillRepeatedly (DoAll (
@@ -369,7 +477,7 @@
369 const VariantTypes &value,477 const VariantTypes &value,
370 CCSSetting *setting,478 CCSSetting *setting,
371 const WriteFunc &write,479 const WriteFunc &write,
372 CCSBackendConceptTestEnvironmentInterface *env)480 const CCSBackendConceptTestEnvironmentInterface::Ptr &env)
373{481{
374 CCSSettingGMock *gmock (getSettingGMockFromSetting (setting));482 CCSSettingGMock *gmock (getSettingGMockFromSetting (setting));
375 EXPECT_CALL (*gmock, getBell (_)).WillRepeatedly (DoAll (483 EXPECT_CALL (*gmock, getBell (_)).WillRepeatedly (DoAll (
@@ -377,7 +485,12 @@
377 boolToBool (boost::get <bool> (value))),485 boolToBool (boost::get <bool> (value))),
378 Return (TRUE)));486 Return (TRUE)));
379 write ();487 write ();
380 EXPECT_EQ (env->ReadBellAtKey (plugin, key), boolToBool (boost::get <bool> (value)));488 bool v (boost::get <bool> (value));
489
490 if (v)
491 EXPECT_THAT (env->ReadBellAtKey (plugin, key), IsTrue ());
492 else
493 EXPECT_THAT (env->ReadBellAtKey (plugin, key), IsFalse ());
381}494}
382495
383void SetMatchWriteExpectation (const std::string &plugin,496void SetMatchWriteExpectation (const std::string &plugin,
@@ -385,7 +498,7 @@
385 const VariantTypes &value,498 const VariantTypes &value,
386 CCSSetting *setting,499 CCSSetting *setting,
387 const WriteFunc &write,500 const WriteFunc &write,
388 CCSBackendConceptTestEnvironmentInterface *env)501 const CCSBackendConceptTestEnvironmentInterface::Ptr &env)
389{502{
390 CCSSettingGMock *gmock (getSettingGMockFromSetting (setting));503 CCSSettingGMock *gmock (getSettingGMockFromSetting (setting));
391 EXPECT_CALL (*gmock, getMatch (_)).WillRepeatedly (DoAll (504 EXPECT_CALL (*gmock, getMatch (_)).WillRepeatedly (DoAll (
@@ -393,7 +506,7 @@
393 const_cast <char *> (boost::get <const char *> (value))),506 const_cast <char *> (boost::get <const char *> (value))),
394 Return (TRUE)));507 Return (TRUE)));
395 write ();508 write ();
396 EXPECT_EQ (env->ReadMatchAtKey (plugin, key), boost::get <const char *> (value));509 EXPECT_EQ (std::string (env->ReadMatchAtKey (plugin, key)), std::string (boost::get <const char *> (value)));
397}510}
398511
399void SetListWriteExpectation (const std::string &plugin,512void SetListWriteExpectation (const std::string &plugin,
@@ -401,21 +514,24 @@
401 const VariantTypes &value,514 const VariantTypes &value,
402 CCSSetting *setting,515 CCSSetting *setting,
403 const WriteFunc &write,516 const WriteFunc &write,
404 CCSBackendConceptTestEnvironmentInterface *env)517 const CCSBackendConceptTestEnvironmentInterface::Ptr &env)
405{518{
406 CCSSettingGMock *gmock (getSettingGMockFromSetting (setting));519 CCSSettingGMock *gmock (getSettingGMockFromSetting (setting));
407 CCSSettingValueList list = *(boost::get <boost::shared_ptr <CCSListWrapper> > (value));520 CCSSettingValueList list = *(boost::get <boost::shared_ptr <CCSListWrapper> > (value));
408 boost::shared_ptr <CCSSettingInfo> info (boost::make_shared <CCSSettingInfo> ());521
522 EXPECT_CALL (*gmock, getInfo ());
523
524 CCSSettingInfo *info = ccsSettingGetInfo (setting);
409525
410 info->forList.listType = (boost::get <boost::shared_ptr <CCSListWrapper> > (value))->type ();526 info->forList.listType = (boost::get <boost::shared_ptr <CCSListWrapper> > (value))->type ();
411527
412 EXPECT_CALL (*gmock, getInfo ()).WillRepeatedly (Return (info.get ()));528 EXPECT_CALL (*gmock, getInfo ()).Times (AtLeast (1));
413 EXPECT_CALL (*gmock, getList (_)).WillRepeatedly (DoAll (529 EXPECT_CALL (*gmock, getList (_)).WillRepeatedly (DoAll (
414 SetArgPointee <0> (530 SetArgPointee <0> (
415 list),531 list),
416 Return (TRUE)));532 Return (TRUE)));
417 write ();533 write ();
418 EXPECT_THAT (env->ReadListAtKey (plugin, key), ListEqual (ccsSettingGetInfo (setting)->forList, list));534 EXPECT_THAT (env->ReadListAtKey (plugin, key, info), ListEqual (ccsSettingGetInfo (setting)->forList, list));
419}535}
420536
421void SetIntReadExpectation (CCSSettingGMock *gmock, const VariantTypes &value)537void SetIntReadExpectation (CCSSettingGMock *gmock, const VariantTypes &value)
@@ -425,12 +541,22 @@
425541
426void SetBoolReadExpectation (CCSSettingGMock *gmock, const VariantTypes &value)542void SetBoolReadExpectation (CCSSettingGMock *gmock, const VariantTypes &value)
427{543{
428 EXPECT_CALL (*gmock, setBool (boolToBool (boost::get <bool> (value)), _));544 bool v (boost::get <bool> (value));
545
546 if (v)
547 EXPECT_CALL (*gmock, setBool (IsTrue (), _));
548 else
549 EXPECT_CALL (*gmock, setBool (IsFalse (), _));
429}550}
430551
431void SetBellReadExpectation (CCSSettingGMock *gmock, const VariantTypes &value)552void SetBellReadExpectation (CCSSettingGMock *gmock, const VariantTypes &value)
432{553{
433 EXPECT_CALL (*gmock, setBell (boolToBool (boost::get <bool> (value)), _));554 bool v (boost::get <bool> (value));
555
556 if (v)
557 EXPECT_CALL (*gmock, setBell (IsTrue (), _));
558 else
559 EXPECT_CALL (*gmock, setBell (IsFalse (), _));
434}560}
435561
436void SetFloatReadExpectation (CCSSettingGMock *gmock, const VariantTypes &value)562void SetFloatReadExpectation (CCSSettingGMock *gmock, const VariantTypes &value)
@@ -468,14 +594,15 @@
468 EXPECT_CALL (*gmock, setEdge (boost::get <unsigned int> (value), _));594 EXPECT_CALL (*gmock, setEdge (boost::get <unsigned int> (value), _));
469}595}
470596
597CCSSettingInfo globalListInfo;
598
471void SetListReadExpectation (CCSSettingGMock *gmock, const VariantTypes &value)599void SetListReadExpectation (CCSSettingGMock *gmock, const VariantTypes &value)
472{600{
473 CCSSettingInfo info;601 globalListInfo.forList.listType = (boost::get <boost::shared_ptr <CCSListWrapper> > (value))->type ();
474602 globalListInfo.forList.listInfo = NULL;
475 info.forList.listType = (boost::get <boost::shared_ptr <CCSListWrapper> > (value))->type ();603
476 info.forList.listInfo = NULL;604 ON_CALL (*gmock, getInfo ()).WillByDefault (Return (&globalListInfo));
477605 EXPECT_CALL (*gmock, setList (ListEqual (globalListInfo.forList, *(boost::get <boost::shared_ptr <CCSListWrapper> > (value))), _));
478 EXPECT_CALL (*gmock, setList (ListEqual (info.forList, *(boost::get <boost::shared_ptr <CCSListWrapper> > (value))), _));
479}606}
480607
481}608}
@@ -486,9 +613,10 @@
486613
487 typedef boost::shared_ptr <CCSBackendConceptTestParamInterface> Ptr;614 typedef boost::shared_ptr <CCSBackendConceptTestParamInterface> Ptr;
488615
489 typedef boost::function <void (const std::string &plugin,616 typedef void (CCSBackendConceptTestEnvironmentInterface::*NativeWriteMethod) (const std::string &plugin,
490 const std::string &keyname,617 const std::string &keyname,
491 const VariantTypes &value)> NativeWriteMethod;618 const VariantTypes &value);
619
492 typedef boost::function <void (CCSSettingGMock *,620 typedef boost::function <void (CCSSettingGMock *,
493 const VariantTypes &)> SetReadExpectation;621 const VariantTypes &)> SetReadExpectation;
494 typedef boost::function <void (const std::string &,622 typedef boost::function <void (const std::string &,
@@ -496,11 +624,16 @@
496 const VariantTypes &,624 const VariantTypes &,
497 CCSSetting *,625 CCSSetting *,
498 const WriteFunc &,626 const WriteFunc &,
499 CCSBackendConceptTestEnvironmentInterface *)> SetWriteExpectation;627 const CCSBackendConceptTestEnvironmentInterface::Ptr & )> SetWriteExpectation;
500628
501 virtual CCSBackendConceptTestEnvironmentInterface * testEnv () = 0;629 virtual void TearDown (CCSBackend *) = 0;
630
631 virtual CCSBackendConceptTestEnvironmentInterface::Ptr testEnv () = 0;
502 virtual VariantTypes & value () = 0;632 virtual VariantTypes & value () = 0;
503 virtual NativeWriteMethod & nativeWrite () = 0;633 virtual void nativeWrite (const CCSBackendConceptTestEnvironmentInterface::Ptr & iface,
634 const std::string &plugin,
635 const std::string &keyname,
636 const VariantTypes &value) = 0;
504 virtual CCSSettingType & type () = 0;637 virtual CCSSettingType & type () = 0;
505 virtual std::string & keyname () = 0;638 virtual std::string & keyname () = 0;
506 virtual SetWriteExpectation & setWriteExpectationAndWrite () = 0;639 virtual SetWriteExpectation & setWriteExpectationAndWrite () = 0;
@@ -516,7 +649,7 @@
516649
517 typedef boost::shared_ptr <CCSBackendConceptTestParam <I> > Ptr;650 typedef boost::shared_ptr <CCSBackendConceptTestParam <I> > Ptr;
518651
519 CCSBackendConceptTestParam (CCSBackendConceptTestEnvironmentInterface *testEnv,652 CCSBackendConceptTestParam (CCSBackendConceptTestEnvironmentFactoryInterface *testEnvFactory,
520 const VariantTypes &value,653 const VariantTypes &value,
521 const NativeWriteMethod &write,654 const NativeWriteMethod &write,
522 const CCSSettingType &type,655 const CCSSettingType &type,
@@ -524,7 +657,8 @@
524 const SetReadExpectation &setReadExpectation,657 const SetReadExpectation &setReadExpectation,
525 const SetWriteExpectation &setWriteExpectation,658 const SetWriteExpectation &setWriteExpectation,
526 const std::string &what) :659 const std::string &what) :
527 mTestEnv (testEnv),660 mTestEnvFactory (testEnvFactory),
661 mTestEnv (),
528 mValue (value),662 mValue (value),
529 mNativeWrite (write),663 mNativeWrite (write),
530 mType (type),664 mType (type),
@@ -535,9 +669,30 @@
535 {669 {
536 }670 }
537671
538 CCSBackendConceptTestEnvironmentInterface * testEnv () { return mTestEnv; }672 void TearDown (CCSBackend *b)
673 {
674 if (mTestEnv)
675 mTestEnv->TearDown (b);
676
677 mTestEnv.reset ();
678 }
679
680 CCSBackendConceptTestEnvironmentInterface::Ptr testEnv ()
681 {
682 if (!mTestEnv)
683 mTestEnv = mTestEnvFactory->ConstructTestEnv ();
684
685 return mTestEnv;
686 }
687
539 VariantTypes & value () { return mValue; }688 VariantTypes & value () { return mValue; }
540 CCSBackendConceptTestParamInterface::NativeWriteMethod & nativeWrite () { return mNativeWrite; }689 void nativeWrite (const CCSBackendConceptTestEnvironmentInterface::Ptr & iface,
690 const std::string &plugin,
691 const std::string &keyname,
692 const VariantTypes &value)
693 {
694 return ((iface.get ())->*mNativeWrite) (plugin, keyname, value);
695 }
541 CCSSettingType & type () { return mType; }696 CCSSettingType & type () { return mType; }
542 std::string & keyname () { return mKeyname; }697 std::string & keyname () { return mKeyname; }
543 CCSBackendConceptTestParamInterface::SetReadExpectation & setReadExpectation () { return mSetReadExpectation; }698 CCSBackendConceptTestParamInterface::SetReadExpectation & setReadExpectation () { return mSetReadExpectation; }
@@ -546,7 +701,8 @@
546701
547 private:702 private:
548703
549 CCSBackendConceptTestEnvironmentInterface *mTestEnv;704 CCSBackendConceptTestEnvironmentFactoryInterface *mTestEnvFactory;
705 CCSBackendConceptTestEnvironmentInterface::Ptr mTestEnv;
550 VariantTypes mValue;706 VariantTypes mValue;
551 NativeWriteMethod mNativeWrite;707 NativeWriteMethod mNativeWrite;
552 CCSSettingType mType;708 CCSSettingType mType;
@@ -586,7 +742,7 @@
586742
587 virtual void TearDown ()743 virtual void TearDown ()
588 {744 {
589 CCSBackendConformanceTest::GetParam ()->testEnv ()->TearDown (mBackend);745 CCSBackendConformanceTest::GetParam ()->TearDown (mBackend);
590746
591 for (std::list <CCSContext *>::iterator it = mSpawnedContexts.begin ();747 for (std::list <CCSContext *>::iterator it = mSpawnedContexts.begin ();
592 it != mSpawnedContexts.end ();748 it != mSpawnedContexts.end ();
@@ -640,6 +796,7 @@
640 {796 {
641 *setting = ccsMockSettingNew ();797 *setting = ccsMockSettingNew ();
642 mSpawnedSettings.push_back (*setting);798 mSpawnedSettings.push_back (*setting);
799 mSpawnedSettingInfo.push_back (CCSSettingInfo ());
643800
644 CCSSettingGMock *gmockSetting = (CCSSettingGMock *) ccsObjectGetPrivate (*setting);801 CCSSettingGMock *gmockSetting = (CCSSettingGMock *) ccsObjectGetPrivate (*setting);
645802
@@ -650,6 +807,7 @@
650 ON_CALL (*gmockSetting, getName ()).WillByDefault (Return ((char *) name.c_str ()));807 ON_CALL (*gmockSetting, getName ()).WillByDefault (Return ((char *) name.c_str ()));
651 ON_CALL (*gmockSetting, getType ()).WillByDefault (Return (type));808 ON_CALL (*gmockSetting, getType ()).WillByDefault (Return (type));
652 ON_CALL (*gmockSetting, getParent ()).WillByDefault (Return (plugin));809 ON_CALL (*gmockSetting, getParent ()).WillByDefault (Return (plugin));
810 ON_CALL (*gmockSetting, getInfo ()).WillByDefault (Return (&(mSpawnedSettingInfo.back ())));
653 }811 }
654812
655 protected:813 protected:
@@ -662,6 +820,7 @@
662 std::list <CCSContext *> mSpawnedContexts;820 std::list <CCSContext *> mSpawnedContexts;
663 std::list <CCSPlugin *> mSpawnedPlugins;821 std::list <CCSPlugin *> mSpawnedPlugins;
664 std::list <CCSSetting *> mSpawnedSettings;822 std::list <CCSSetting *> mSpawnedSettings;
823 std::vector <CCSSettingInfo> mSpawnedSettingInfo;
665824
666 CCSBackend *mBackend;825 CCSBackend *mBackend;
667826
@@ -680,155 +839,209 @@
680float floatValues[] = { 1.0, 2.0, 3.0 };839float floatValues[] = { 1.0, 2.0, 3.0 };
681const char * stringValues[] = { "foo", "grill", "bar" };840const char * stringValues[] = { "foo", "grill", "bar" };
682841
683CCSSettingColorValue colorValues[3] = { { .color = { 100, 200, 300, 100 } },842const unsigned int NUM_COLOR_VALUES = 3;
684 { .color = { 50, 100, 200, 300 } },843
685 { .color = { 10, 20, 30, 40 } }844CCSSettingColorValue *
686 };845getColorValueList ()
687846{
688CCSSettingKeyValue keyValue = { (1 << 0) | (1 << 1),847 static const unsigned short max = std::numeric_limits <unsigned short>::max ();
689 1 };848 static const unsigned short maxD2 = max / 2;
690849 static const unsigned short maxD4 = max / 4;
691CCSSettingButtonValue buttonValue = { (1 << 0) | (1 << 1),850 static const unsigned short maxD8 = max / 8;
692 1,851
852 static CCSSettingColorValue colorValues[NUM_COLOR_VALUES] = { { .color = { maxD2, maxD4, maxD8, max } },
853 { .color = { maxD8, maxD4, maxD2, max } },
854 { .color = { max, maxD4, maxD2, maxD8 } }
855 };
856 static bool colorValueListInitialized = false;
857
858 if (!colorValueListInitialized)
859 {
860 for (unsigned int i = 0; i < NUM_COLOR_VALUES; i++)
861 {
862 CharacterWrapper s (ccsColorToString (&colorValues[i]));
863
864 ccsStringToColor (s, &colorValues[i]);
865 }
866
867 colorValueListInitialized = true;
868 }
869
870 return colorValues;
871}
872
873CCSSettingKeyValue keyValue = { XK_A,
874 (1 << 0)};
875
876CCSSettingButtonValue buttonValue = { 1,
877 (1 << 0),
693 (1 << 1) };878 (1 << 1) };
879
880}
881
882typedef boost::function <CCSSettingValueList (CCSSetting *)> ConstructorFunc;
883
884CCSListWrapper::Ptr
885CCSListConstructionExpectationsSetter (const ConstructorFunc &c,
886 CCSSettingType type,
887 bool freeItems)
888{
889 boost::function <void (CCSSetting *)> f (boost::bind (ccsFreeMockSetting, _1));
890 boost::shared_ptr <CCSSetting> mockSetting (ccsMockSettingNew (), f);
891 CCSSettingGMock *gmockSetting = reinterpret_cast <CCSSettingGMock *> (ccsObjectGetPrivate (mockSetting.get ()));
892
893 EXPECT_CALL (*gmockSetting, getType ()).WillRepeatedly (Return (TypeList));
894
895 boost::shared_ptr <CCSSettingInfo> listInfo (new CCSSettingInfo);
896
897 listInfo->forList.listType = type;
898
899 EXPECT_CALL (*gmockSetting, getInfo ()).WillRepeatedly (Return (listInfo.get ()));
900 EXPECT_CALL (*gmockSetting, getDefaultValue ()).WillRepeatedly (ReturnNull ());
901 return boost::make_shared <CCSListWrapper> (c (mockSetting.get ()), freeItems, type, listInfo, mockSetting);
694}902}
695903
696template <typename I>904template <typename I>
697::testing::internal::ParamGenerator<typename CCSBackendConceptTestParamInterface::Ptr>905::testing::internal::ParamGenerator<typename CCSBackendConceptTestParamInterface::Ptr>
698GenerateTestingParametersForBackendInterface ()906GenerateTestingParametersForBackendInterface ()
699{907{
700 static I interface;908 static CCSBackendConceptTestEnvironmentFactory <I> interfaceFactory;
701 static CCSBackendConceptTestEnvironmentInterface *backendEnv = &interface;909 static CCSBackendConceptTestEnvironmentFactoryInterface *backendEnvFactory = &interfaceFactory;
702910
703 typedef CCSBackendConceptTestParam<I> ConceptParam;911 typedef CCSBackendConceptTestParam<I> ConceptParam;
704912
705 static typename CCSBackendConceptTestParamInterface::Ptr testParam[] =913 static typename CCSBackendConceptTestParamInterface::Ptr testParam[] =
706 {914 {
707 boost::make_shared <ConceptParam> (backendEnv,915 boost::make_shared <ConceptParam> (backendEnvFactory,
708 VariantTypes (1),916 VariantTypes (1),
709 boost::bind (&CCSBackendConceptTestEnvironmentInterface::WriteIntegerAtKey, backendEnv, _1, _2, _3),917 &CCSBackendConceptTestEnvironmentInterface::WriteIntegerAtKey,
710 TypeInt,918 TypeInt,
711 "integer_setting",919 "integer_setting",
712 boost::bind (SetIntReadExpectation, _1, _2),920 boost::bind (SetIntReadExpectation, _1, _2),
713 boost::bind (SetIntWriteExpectation, _1, _2, _3, _4, _5, _6),921 boost::bind (SetIntWriteExpectation, _1, _2, _3, _4, _5, _6),
714 "TestInt"),922 "TestInt"),
715 boost::make_shared <ConceptParam> (backendEnv,923 boost::make_shared <ConceptParam> (backendEnvFactory,
716 VariantTypes (true),924 VariantTypes (true),
717 boost::bind (&CCSBackendConceptTestEnvironmentInterface::WriteBoolAtKey, backendEnv, _1, _2, _3),925 &CCSBackendConceptTestEnvironmentInterface::WriteBoolAtKey,
718 TypeBool,926 TypeBool,
719 "boolean_setting",927 "boolean_setting",
720 boost::bind (SetBoolReadExpectation, _1, _2),928 boost::bind (SetBoolReadExpectation, _1, _2),
721 boost::bind (SetBoolWriteExpectation, _1, _2, _3, _4, _5, _6),929 boost::bind (SetBoolWriteExpectation, _1, _2, _3, _4, _5, _6),
722 "TestBool"),930 "TestBool"),
723 boost::make_shared <ConceptParam> (backendEnv,931 boost::make_shared <ConceptParam> (backendEnvFactory,
724 VariantTypes (static_cast <float> (3.0)),932 VariantTypes (static_cast <float> (3.0)),
725 boost::bind (&CCSBackendConceptTestEnvironmentInterface::WriteFloatAtKey, backendEnv, _1, _2, _3),933 &CCSBackendConceptTestEnvironmentInterface::WriteFloatAtKey,
726 TypeFloat,934 TypeFloat,
727 "float_setting",935 "float_setting",
728 boost::bind (SetFloatReadExpectation, _1, _2),936 boost::bind (SetFloatReadExpectation, _1, _2),
729 boost::bind (SetFloatWriteExpectation, _1, _2, _3, _4, _5, _6),937 boost::bind (SetFloatWriteExpectation, _1, _2, _3, _4, _5, _6),
730 "TestFloat"),938 "TestFloat"),
731 boost::make_shared <ConceptParam> (backendEnv,939 boost::make_shared <ConceptParam> (backendEnvFactory,
732 VariantTypes (static_cast <const char *> ("foo")),940 VariantTypes (static_cast <const char *> ("foo")),
733 boost::bind (&CCSBackendConceptTestEnvironmentInterface::WriteStringAtKey, backendEnv, _1, _2, _3),941 &CCSBackendConceptTestEnvironmentInterface::WriteStringAtKey,
734 TypeString,942 TypeString,
735 "string_setting",943 "string_setting",
736 boost::bind (SetStringReadExpectation, _1, _2),944 boost::bind (SetStringReadExpectation, _1, _2),
737 boost::bind (SetStringWriteExpectation, _1, _2, _3, _4, _5, _6),945 boost::bind (SetStringWriteExpectation, _1, _2, _3, _4, _5, _6),
738 "TestString"),946 "TestString"),
739 boost::make_shared <ConceptParam> (backendEnv,947 boost::make_shared <ConceptParam> (backendEnvFactory,
740 VariantTypes (static_cast <const char *> ("foo=bar")),948 VariantTypes (static_cast <const char *> ("foo=bar")),
741 boost::bind (&CCSBackendConceptTestEnvironmentInterface::WriteMatchAtKey, backendEnv, _1, _2, _3),949 &CCSBackendConceptTestEnvironmentInterface::WriteMatchAtKey,
742 TypeMatch,950 TypeMatch,
743 "match_setting",951 "match_setting",
744 boost::bind (SetMatchReadExpectation, _1, _2),952 boost::bind (SetMatchReadExpectation, _1, _2),
745 boost::bind (SetMatchWriteExpectation, _1, _2, _3, _4, _5, _6),953 boost::bind (SetMatchWriteExpectation, _1, _2, _3, _4, _5, _6),
746 "TestMatch"),954 "TestMatch"),
747 boost::make_shared <ConceptParam> (backendEnv,955 boost::make_shared <ConceptParam> (backendEnvFactory,
748 VariantTypes (true),956 VariantTypes (true),
749 boost::bind (&CCSBackendConceptTestEnvironmentInterface::WriteBellAtKey, backendEnv, _1, _2, _3),957 &CCSBackendConceptTestEnvironmentInterface::WriteBellAtKey,
750 TypeBell,958 TypeBell,
751 "bell_setting",959 "bell_setting",
752 boost::bind (SetBellReadExpectation, _1, _2),960 boost::bind (SetBellReadExpectation, _1, _2),
753 boost::bind (SetBellWriteExpectation, _1, _2, _3, _4, _5, _6),961 boost::bind (SetBellWriteExpectation, _1, _2, _3, _4, _5, _6),
754 "TestBell"),962 "TestBell"),
755 boost::make_shared <ConceptParam> (backendEnv,963 boost::make_shared <ConceptParam> (backendEnvFactory,
756 VariantTypes (impl::colorValues[0]),964 VariantTypes (impl::getColorValueList ()[0]),
757 boost::bind (&CCSBackendConceptTestEnvironmentInterface::WriteColorAtKey, backendEnv, _1, _2, _3),965 &CCSBackendConceptTestEnvironmentInterface::WriteColorAtKey,
758 TypeColor,966 TypeColor,
759 "color_setting",967 "color_setting",
760 boost::bind (SetColorReadExpectation, _1, _2),968 boost::bind (SetColorReadExpectation, _1, _2),
761 boost::bind (SetColorWriteExpectation, _1, _2, _3, _4, _5, _6),969 boost::bind (SetColorWriteExpectation, _1, _2, _3, _4, _5, _6),
762 "TestColor"),970 "TestColor"),
763 boost::make_shared <ConceptParam> (backendEnv,971 boost::make_shared <ConceptParam> (backendEnvFactory,
764 VariantTypes (impl::keyValue),972 VariantTypes (impl::keyValue),
765 boost::bind (&CCSBackendConceptTestEnvironmentInterface::WriteKeyAtKey, backendEnv, _1, _2, _3),973 &CCSBackendConceptTestEnvironmentInterface::WriteKeyAtKey,
766 TypeKey,974 TypeKey,
767 "key_setting",975 "key_setting",
768 boost::bind (SetKeyReadExpectation, _1, _2),976 boost::bind (SetKeyReadExpectation, _1, _2),
769 boost::bind (SetKeyWriteExpectation, _1, _2, _3, _4, _5, _6),977 boost::bind (SetKeyWriteExpectation, _1, _2, _3, _4, _5, _6),
770 "TestKey"),978 "TestKey"),
771 boost::make_shared <ConceptParam> (backendEnv,979 boost::make_shared <ConceptParam> (backendEnvFactory,
772 VariantTypes (impl::buttonValue),980 VariantTypes (impl::buttonValue),
773 boost::bind (&CCSBackendConceptTestEnvironmentInterface::WriteButtonAtKey, backendEnv, _1, _2, _3),981 &CCSBackendConceptTestEnvironmentInterface::WriteButtonAtKey,
774 TypeButton,982 TypeButton,
775 "button_setting",983 "button_setting",
776 boost::bind (SetButtonReadExpectation, _1, _2),984 boost::bind (SetButtonReadExpectation, _1, _2),
777 boost::bind (SetButtonWriteExpectation, _1, _2, _3, _4, _5, _6),985 boost::bind (SetButtonWriteExpectation, _1, _2, _3, _4, _5, _6),
778 "TestButton"),986 "TestButton"),
779 boost::make_shared <ConceptParam> (backendEnv,987 boost::make_shared <ConceptParam> (backendEnvFactory,
780 VariantTypes (static_cast <unsigned int> (1)),988 VariantTypes (static_cast <unsigned int> (1)),
781 boost::bind (&CCSBackendConceptTestEnvironmentInterface::WriteEdgeAtKey, backendEnv, _1, _2, _3),989 &CCSBackendConceptTestEnvironmentInterface::WriteEdgeAtKey,
782 TypeEdge,990 TypeEdge,
783 "edge_setting",991 "edge_setting",
784 boost::bind (SetEdgeReadExpectation, _1, _2),992 boost::bind (SetEdgeReadExpectation, _1, _2),
785 boost::bind (SetEdgeWriteExpectation, _1, _2, _3, _4, _5, _6),993 boost::bind (SetEdgeWriteExpectation, _1, _2, _3, _4, _5, _6),
786 "TestEdge"),994 "TestEdge"),
787 boost::make_shared <ConceptParam> (backendEnv,995 boost::make_shared <ConceptParam> (backendEnvFactory,
788 VariantTypes (boost::make_shared <CCSListWrapper> (ccsGetValueListFromIntArray (impl::intValues,996 VariantTypes (CCSListConstructionExpectationsSetter (boost::bind (ccsGetValueListFromIntArray,
789 sizeof (impl::intValues) / sizeof (impl::intValues[0]),997 impl::intValues,
790 NULL), false, TypeInt)),998 sizeof (impl::intValues) / sizeof (impl::intValues[0]), _1),
791 boost::bind (&CCSBackendConceptTestEnvironmentInterface::WriteListAtKey, backendEnv, _1, _2, _3),999 TypeInt, true)),
1000 &CCSBackendConceptTestEnvironmentInterface::WriteListAtKey,
792 TypeList,1001 TypeList,
793 "int_list_setting",1002 "int_list_setting",
794 boost::bind (SetListReadExpectation, _1, _2),1003 boost::bind (SetListReadExpectation, _1, _2),
795 boost::bind (SetListWriteExpectation, _1, _2, _3, _4, _5, _6),1004 boost::bind (SetListWriteExpectation, _1, _2, _3, _4, _5, _6),
796 "TestListInt"),1005 "TestListInt"),
797 boost::make_shared <ConceptParam> (backendEnv,1006 boost::make_shared <ConceptParam> (backendEnvFactory,
798 VariantTypes (boost::make_shared <CCSListWrapper> (ccsGetValueListFromFloatArray (impl::floatValues,1007 VariantTypes (CCSListConstructionExpectationsSetter (boost::bind (ccsGetValueListFromFloatArray,
799 sizeof (impl::floatValues) / sizeof (impl::floatValues[0]),1008 impl::floatValues,
800 NULL), false, TypeFloat)),1009 sizeof (impl::floatValues) / sizeof (impl::floatValues[0]), _1),
801 boost::bind (&CCSBackendConceptTestEnvironmentInterface::WriteListAtKey, backendEnv, _1, _2, _3),1010 TypeFloat, true)),
1011 &CCSBackendConceptTestEnvironmentInterface::WriteListAtKey,
802 TypeList,1012 TypeList,
803 "float_list_setting",1013 "float_list_setting",
804 boost::bind (SetListReadExpectation, _1, _2),1014 boost::bind (SetListReadExpectation, _1, _2),
805 boost::bind (SetListWriteExpectation, _1, _2, _3, _4, _5, _6),1015 boost::bind (SetListWriteExpectation, _1, _2, _3, _4, _5, _6),
806 "TestListInt"),1016 "TestListFloat"),
807 boost::make_shared <ConceptParam> (backendEnv,1017 boost::make_shared <ConceptParam> (backendEnvFactory,
808 VariantTypes (boost::make_shared <CCSListWrapper> (ccsGetValueListFromBoolArray (impl::boolValues,1018 VariantTypes (CCSListConstructionExpectationsSetter (boost::bind (ccsGetValueListFromBoolArray,
809 sizeof (impl::boolValues) / sizeof (impl::boolValues[0]),1019 impl::boolValues,
810 NULL), false, TypeBool)),1020 sizeof (impl::boolValues) / sizeof (impl::boolValues[0]), _1),
811 boost::bind (&CCSBackendConceptTestEnvironmentInterface::WriteListAtKey, backendEnv, _1, _2, _3),1021 TypeBool, true)),
1022 &CCSBackendConceptTestEnvironmentInterface::WriteListAtKey,
812 TypeList,1023 TypeList,
813 "bool_list_setting",1024 "bool_list_setting",
814 boost::bind (SetListReadExpectation, _1, _2),1025 boost::bind (SetListReadExpectation, _1, _2),
815 boost::bind (SetListWriteExpectation, _1, _2, _3, _4, _5, _6),1026 boost::bind (SetListWriteExpectation, _1, _2, _3, _4, _5, _6),
816 "TestListBool"),1027 "TestListBool"),
817 boost::make_shared <ConceptParam> (backendEnv,1028 boost::make_shared <ConceptParam> (backendEnvFactory,
818 VariantTypes (boost::make_shared <CCSListWrapper> (ccsGetValueListFromStringArray (impl::stringValues,1029 VariantTypes (CCSListConstructionExpectationsSetter (boost::bind (ccsGetValueListFromStringArray,
819 sizeof (impl::stringValues) / sizeof (impl::stringValues[0]),1030 impl::stringValues,
820 NULL), false, TypeString)),1031 sizeof (impl::stringValues) / sizeof (impl::stringValues[0]), _1),
821 boost::bind (&CCSBackendConceptTestEnvironmentInterface::WriteListAtKey, backendEnv, _1, _2, _3),1032 TypeString, true)),
1033 &CCSBackendConceptTestEnvironmentInterface::WriteListAtKey,
822 TypeList,1034 TypeList,
823 "string_list_setting",1035 "string_list_setting",
824 boost::bind (SetListReadExpectation, _1, _2),1036 boost::bind (SetListReadExpectation, _1, _2),
825 boost::bind (SetListWriteExpectation, _1, _2, _3, _4, _5, _6),1037 boost::bind (SetListWriteExpectation, _1, _2, _3, _4, _5, _6),
826 "TestListString"),1038 "TestListString"),
827 boost::make_shared <ConceptParam> (backendEnv,1039 boost::make_shared <ConceptParam> (backendEnvFactory,
828 VariantTypes (boost::make_shared <CCSListWrapper> (ccsGetValueListFromColorArray (impl::colorValues,1040 VariantTypes (CCSListConstructionExpectationsSetter (boost::bind (ccsGetValueListFromColorArray,
829 sizeof (impl::colorValues) / sizeof (impl::colorValues[0]),1041 impl::getColorValueList (),
830 NULL), false, TypeColor)),1042 impl::NUM_COLOR_VALUES, _1),
831 boost::bind (&CCSBackendConceptTestEnvironmentInterface::WriteListAtKey, backendEnv, _1, _2, _3),1043 TypeColor, true)),
1044 &CCSBackendConceptTestEnvironmentInterface::WriteListAtKey,
832 TypeList,1045 TypeList,
833 "color_list_setting",1046 "color_list_setting",
834 boost::bind (SetListReadExpectation, _1, _2),1047 boost::bind (SetListReadExpectation, _1, _2),
@@ -885,31 +1098,62 @@
885 SCOPED_TRACE (CCSBackendConformanceTest::GetParam ()->what () + "Read");1098 SCOPED_TRACE (CCSBackendConformanceTest::GetParam ()->what () + "Read");
8861099
887 CCSBackendConformanceTest::GetParam ()->testEnv ()->PreRead (gmockContext, gmockPlugin, gmockSetting, GetParam ()->type ());1100 CCSBackendConformanceTest::GetParam ()->testEnv ()->PreRead (gmockContext, gmockPlugin, gmockSetting, GetParam ()->type ());
888 CCSBackendConformanceTest::GetParam ()->nativeWrite () (pluginName, settingName, VALUE);1101 CCSBackendConformanceTest::GetParam ()->nativeWrite (CCSBackendConformanceTest::GetParam ()->testEnv (),
1102 pluginName, settingName, VALUE);
889 CCSBackendConformanceTest::GetParam ()->testEnv ()->PostRead (gmockContext, gmockPlugin, gmockSetting, GetParam ()->type ());1103 CCSBackendConformanceTest::GetParam ()->testEnv ()->PostRead (gmockContext, gmockPlugin, gmockSetting, GetParam ()->type ());
890 CCSBackendConformanceTest::GetParam ()->setReadExpectation () (gmockSetting, VALUE);1104 CCSBackendConformanceTest::GetParam ()->setReadExpectation () (gmockSetting, VALUE);
8911105
892 ccsBackendReadSetting (CCSBackendConformanceTest::GetBackend (), context, setting);1106 ccsBackendReadSetting (CCSBackendConformanceTest::GetBackend (), context, setting);
893}1107}
8941108
1109TEST_P (CCSBackendConformanceTestReadWrite, TestUpdateMockedValue)
1110{
1111 SCOPED_TRACE (CCSBackendConformanceTest::GetParam ()->what () + "UpdateMocked");
1112
1113 CCSBackendConformanceTest::GetParam ()->testEnv ()->PreUpdate (gmockContext, gmockPlugin, gmockSetting, GetParam ()->type ());
1114 CCSBackendConformanceTest::GetParam ()->nativeWrite (CCSBackendConformanceTest::GetParam ()->testEnv (),
1115 pluginName, settingName, VALUE);
1116 CCSBackendConformanceTest::GetParam ()->testEnv ()->PostUpdate (gmockContext, gmockPlugin, gmockSetting, GetParam ()->type ());
1117 CCSBackendConformanceTest::GetParam ()->setReadExpectation () (gmockSetting, VALUE);
1118
1119 ccsBackendUpdateSetting (CCSBackendConformanceTest::GetBackend (), context, plugin, setting);
1120}
1121
1122TEST_P (CCSBackendConformanceTestReadWrite, TestUpdateKeyedValue)
1123{
1124 SCOPED_TRACE (CCSBackendConformanceTest::GetParam ()->what () + "UpdateMocked");
1125
1126 CCSBackendConformanceTest::GetParam ()->testEnv ()->PreUpdate (gmockContext, gmockPlugin, gmockSetting, GetParam ()->type ());
1127 CCSBackendConformanceTest::GetParam ()->nativeWrite (CCSBackendConformanceTest::GetParam ()->testEnv (),
1128 pluginName, settingName, VALUE);
1129 CCSBackendConformanceTest::GetParam ()->testEnv ()->PostUpdate (gmockContext, gmockPlugin, gmockSetting, GetParam ()->type ());
1130 CCSBackendConformanceTest::GetParam ()->setReadExpectation () (gmockSetting, VALUE);
1131
1132 EXPECT_CALL (*gmockContext, findPlugin (_)).WillOnce (Return (plugin));
1133 EXPECT_CALL (*gmockPlugin, findSetting (_)).WillOnce (Return (setting));
1134
1135 EXPECT_TRUE (CCSBackendConformanceTest::GetParam ()->testEnv ()->UpdateSettingAtKey (pluginName, settingName));
1136}
1137
895TEST_P (CCSBackendConformanceTestReadWrite, TestWriteValue)1138TEST_P (CCSBackendConformanceTestReadWrite, TestWriteValue)
896{1139{
897 SCOPED_TRACE (CCSBackendConformanceTest::GetParam ()->what () + "Write");1140 SCOPED_TRACE (CCSBackendConformanceTest::GetParam ()->what () + "Write");
8981141
899 CCSBackendConformanceTest::GetParam ()->testEnv ()->PreWrite (gmockContext, gmockPlugin, gmockSetting, GetParam ()->type ());1142 CCSBackendConformanceTest::GetParam ()->testEnv ()->PreWrite (gmockContext, gmockPlugin, gmockSetting, GetParam ()->type ());
900 CCSBackendConformanceTest::GetParam ()->setWriteExpectationAndWrite () (pluginName,1143 CCSBackendConformanceTest::GetParam ()->setWriteExpectationAndWrite () (pluginName,
901 settingName,1144 settingName,
902 VALUE,1145 VALUE,
903 setting,1146 setting,
904 boost::bind (ccsBackendWriteSetting,1147 boost::bind (ccsBackendWriteSetting,
905 CCSBackendConformanceTest::GetBackend (),1148 CCSBackendConformanceTest::GetBackend (),
906 context,1149 context,
907 setting),1150 setting),
908 GetParam ()->testEnv ());1151 GetParam ()->testEnv ());
909 CCSBackendConformanceTest::GetParam ()->testEnv ()->PostWrite (gmockContext, gmockPlugin, gmockSetting, GetParam ()->type ());1152 CCSBackendConformanceTest::GetParam ()->testEnv ()->PostWrite (gmockContext, gmockPlugin, gmockSetting, GetParam ()->type ());
9101153
911}1154}
9121155
9131156
1157
914#endif1158#endif
9151159

Subscribers

People subscribed via source and target branches