Merge lp:~compiz-team/compiz/compiz.gsettings_conformance_test into lp:compiz/0.9.8
- compiz.gsettings_conformance_test
- Merge into 0.9.8
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 |
Related bugs: |
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.
Commit message
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.
- 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 translateKeyFor
GSettings 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 CCSGSettingsBac
kendConcept/ CCSBackendConfo rmanceTestReadW rite - 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 CCSGSettingsTes
tIndependent. TestReadVariant IsValidTypeGood - 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 TestUpdateMocke
dValue - 3387. By Sam Spilsbury
-
Added PostUpdate and PreUpdate hooks into the test fixture so now
MockCCSBackendConcept/ CCSBackendConfo rmanceTestReadW rite.TestUpdate MockedValue/ *
will pass - 3388. By Sam Spilsbury
-
Store path as a const char
- 3389. By Sam Spilsbury
-
Refactor out findSettingAndP
luginToUpdateFr omPath - 3390. By Sam Spilsbury
-
Move it to gsettings_util
- 3391. By Sam Spilsbury
-
Refactor updateSettingWi
thGSettingsKeyN ame - 3392. By Sam Spilsbury
-
Move updateSettingWi
thGSettingsKeyN ame into the util library - 3393. By Sam Spilsbury
-
Added TestUpdateKeyed
Value - all failing - 3394. By Sam Spilsbury
-
Make the mock UpdateSettingAtKey tests pass
- 3395. By Sam Spilsbury
-
Make TestUpdateKeyed
Valu* 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 CCSGSettingsBac
kendEnv: :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_ characterwrappe r.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 CCSGSettingsTes
tFindSettingAnd PluginToUpdateF romPath - 3513. By Sam Spilsbury
-
Comprehensive test coverage for FindSettingAndP
luginToUpdateFr omPath
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 CCSBackendConfo
rmanceTestProfi leHandling 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
1 | === modified file 'compizconfig/gconf/src/gconf.c' |
2 | --- compizconfig/gconf/src/gconf.c 2012-07-21 20:44:19 +0000 |
3 | +++ compizconfig/gconf/src/gconf.c 2012-07-21 20:44:20 +0000 |
4 | @@ -436,6 +436,22 @@ |
5 | } |
6 | |
7 | static void |
8 | +updateSetting (CCSBackend *backend, CCSContext *context, CCSPlugin *plugin, CCSSetting *setting) |
9 | +{ |
10 | + int index; |
11 | + readInit (backend, context); |
12 | + if (!readOption (setting)) |
13 | + ccsResetToDefault (setting, TRUE); |
14 | + |
15 | + if (ccsGetIntegrationEnabled (context) && |
16 | + isIntegratedOption (setting, &index)) |
17 | + { |
18 | + writeInit (backend, context); |
19 | + writeIntegratedOption (context, setting, index); |
20 | + } |
21 | +} |
22 | + |
23 | +static void |
24 | valueChanged (GConfClient *client, |
25 | guint cnxn_id, |
26 | GConfEntry *entry, |
27 | @@ -445,7 +461,6 @@ |
28 | char *keyName = (char*) gconf_entry_get_key (entry); |
29 | char *pluginName; |
30 | char *token; |
31 | - int index; |
32 | unsigned int screenNum; |
33 | CCSPlugin *plugin; |
34 | CCSSetting *setting; |
35 | @@ -490,16 +505,9 @@ |
36 | if (!setting) |
37 | return; |
38 | |
39 | - readInit (NULL, context); |
40 | - if (!readOption (setting)) |
41 | - ccsResetToDefault (setting, TRUE); |
42 | - |
43 | - if (ccsGetIntegrationEnabled (context) && |
44 | - isIntegratedOption (setting, &index)) |
45 | - { |
46 | - writeInit (NULL, context); |
47 | - writeIntegratedOption (context, setting, index); |
48 | - } |
49 | + /* Passing null here is not optimal, but we are not |
50 | + * maintaining gconf actively here */ |
51 | + updateSetting (NULL, context, plugin, setting); |
52 | } |
53 | |
54 | static void |
55 | @@ -2167,6 +2175,7 @@ |
56 | writeInit, |
57 | writeSetting, |
58 | 0, |
59 | + updateSetting, |
60 | getSettingIsIntegrated, |
61 | getSettingIsReadOnly, |
62 | getExistingProfiles, |
63 | |
64 | === modified file 'compizconfig/gsettings/gsettings_backend_shared/gsettings_util.c' |
65 | --- compizconfig/gsettings/gsettings_backend_shared/gsettings_util.c 2012-07-21 20:44:19 +0000 |
66 | +++ compizconfig/gsettings/gsettings_backend_shared/gsettings_util.c 2012-07-21 20:44:20 +0000 |
67 | @@ -4,6 +4,8 @@ |
68 | #include <stdio.h> |
69 | #include "gsettings_shared.h" |
70 | |
71 | +INTERFACE_TYPE (CCSGSettingsBackendInterface); |
72 | + |
73 | GList * |
74 | variantTypeToPossibleSettingType (const gchar *vt) |
75 | { |
76 | @@ -328,6 +330,101 @@ |
77 | return found; |
78 | } |
79 | |
80 | +Bool |
81 | +findSettingAndPluginToUpdateFromPath (GSettings *settings, |
82 | + const char *path, |
83 | + const gchar *keyName, |
84 | + CCSContext *context, |
85 | + CCSPlugin **plugin, |
86 | + CCSSetting **setting, |
87 | + char **uncleanKeyName) |
88 | +{ |
89 | + char *pluginName; |
90 | + unsigned int screenNum; |
91 | + |
92 | + if (!decomposeGSettingsPath (path, &pluginName, &screenNum)) |
93 | + return FALSE; |
94 | + |
95 | + *plugin = ccsFindPlugin (context, pluginName); |
96 | + |
97 | + if (*plugin) |
98 | + { |
99 | + *uncleanKeyName = translateKeyForCCS (keyName); |
100 | + |
101 | + *setting = ccsFindSetting (*plugin, *uncleanKeyName); |
102 | + if (!setting) |
103 | + { |
104 | + /* Couldn't find setting straight off the bat, |
105 | + * try and find the best match */ |
106 | + GVariant *value = g_settings_get_value (settings, keyName); |
107 | + |
108 | + if (value) |
109 | + { |
110 | + GList *possibleSettingTypes = variantTypeToPossibleSettingType (g_variant_get_type_string (value)); |
111 | + GList *iter = possibleSettingTypes; |
112 | + |
113 | + while (iter) |
114 | + { |
115 | + *setting = attemptToFindCCSSettingFromLossyName (ccsGetPluginSettings (*plugin), |
116 | + keyName, |
117 | + (CCSSettingType) GPOINTER_TO_INT (iter->data)); |
118 | + |
119 | + if (*setting) |
120 | + break; |
121 | + |
122 | + iter = iter->next; |
123 | + } |
124 | + |
125 | + g_list_free (possibleSettingTypes); |
126 | + g_variant_unref (value); |
127 | + } |
128 | + } |
129 | + } |
130 | + |
131 | + g_free (pluginName); |
132 | + |
133 | + if (!*plugin || !*setting) |
134 | + return FALSE; |
135 | + |
136 | + return TRUE; |
137 | +} |
138 | + |
139 | +Bool |
140 | +updateSettingWithGSettingsKeyName (CCSBackend *backend, |
141 | + GSettings *settings, |
142 | + gchar *keyName, |
143 | + CCSBackendUpdateFunc updateSetting) |
144 | +{ |
145 | + CCSContext *context = ccsGSettingsBackendGetContext (backend); |
146 | + char *uncleanKeyName = NULL; |
147 | + char *pathOrig; |
148 | + CCSPlugin *plugin; |
149 | + CCSSetting *setting; |
150 | + Bool ret = TRUE; |
151 | + |
152 | + g_object_get (G_OBJECT (settings), "path", &pathOrig, NULL); |
153 | + |
154 | + if (findSettingAndPluginToUpdateFromPath (settings, pathOrig, keyName, context, &plugin, &setting, &uncleanKeyName)) |
155 | + (*updateSetting) (backend, context, plugin, setting); |
156 | + else |
157 | + { |
158 | + /* We hit a situation where either the key stored in GSettings couldn't be |
159 | + * matched at all to a key in the xml file, or where there were multiple matches. |
160 | + * Unfortunately, there isn't much we can do about this, other than try |
161 | + * and warn the user and bail out. It just means that if the key was updated |
162 | + * externally we won't know about the change until the next reload of settings */ |
163 | + ccsWarning ("Unable to find setting %s, for path %s", uncleanKeyName, pathOrig); |
164 | + ret = FALSE; |
165 | + } |
166 | + |
167 | + g_free (pathOrig); |
168 | + |
169 | + if (uncleanKeyName) |
170 | + free (uncleanKeyName); |
171 | + |
172 | + return ret; |
173 | +} |
174 | + |
175 | gchar * |
176 | makeCompizProfilePath (const gchar *profilename) |
177 | { |
178 | @@ -373,7 +470,7 @@ |
179 | } |
180 | |
181 | GVariant * |
182 | -getVariantAtKey (GSettings *settings, char *key, const char *pathName, CCSSettingType type) |
183 | +getVariantAtKey (GSettings *settings, const char *key, const char *pathName, CCSSettingType type) |
184 | { |
185 | GVariant *gsettingsValue = g_settings_get_value (settings, key); |
186 | |
187 | @@ -390,7 +487,7 @@ |
188 | readListValue (GVariant *gsettingsValue, CCSSettingType listType) |
189 | { |
190 | gboolean hasVariantType; |
191 | - unsigned int nItems, i = 0; |
192 | + unsigned int nItems; |
193 | CCSSettingValueList list = NULL; |
194 | GVariantIter iter; |
195 | |
196 | @@ -415,7 +512,7 @@ |
197 | |
198 | /* Reads each item from the variant into arrayCounter */ |
199 | while (g_variant_iter_loop (&iter, "b", &value)) |
200 | - *arrayCounter++ = value; |
201 | + *arrayCounter++ = value ? TRUE : FALSE; |
202 | |
203 | list = ccsGetValueListFromBoolArray (array, nItems, NULL); |
204 | free (array); |
205 | @@ -440,8 +537,8 @@ |
206 | break; |
207 | case TypeFloat: |
208 | { |
209 | - double *array = malloc (nItems * sizeof (double)); |
210 | - double *arrayCounter = array; |
211 | + float *array = malloc (nItems * sizeof (float)); |
212 | + float *arrayCounter = array; |
213 | gdouble value; |
214 | |
215 | if (!array) |
216 | @@ -451,7 +548,7 @@ |
217 | while (g_variant_iter_loop (&iter, "d", &value)) |
218 | *arrayCounter++ = value; |
219 | |
220 | - list = ccsGetValueListFromFloatArray ((float *) array, nItems, NULL); |
221 | + list = ccsGetValueListFromFloatArray (array, nItems, NULL); |
222 | free (array); |
223 | } |
224 | break; |
225 | @@ -477,18 +574,20 @@ |
226 | break; |
227 | case TypeColor: |
228 | { |
229 | - CCSSettingColorValue *array; |
230 | char *colorValue; |
231 | - array = malloc (nItems * sizeof (CCSSettingColorValue)); |
232 | + CCSSettingColorValue *array = calloc (1, nItems * sizeof (CCSSettingColorValue)); |
233 | + unsigned int i = 0; |
234 | + |
235 | if (!array) |
236 | break; |
237 | |
238 | while (g_variant_iter_loop (&iter, "s", &colorValue)) |
239 | { |
240 | - memset (&array[i], 0, sizeof (CCSSettingColorValue)); |
241 | ccsStringToColor (colorValue, |
242 | &array[i]); |
243 | + i++; |
244 | } |
245 | + |
246 | list = ccsGetValueListFromColorArray (array, nItems, NULL); |
247 | free (array); |
248 | } |
249 | @@ -667,7 +766,7 @@ |
250 | return TRUE; |
251 | } |
252 | |
253 | -Bool writeStringToVariant (char *value, GVariant **variant) |
254 | +Bool writeStringToVariant (const char *value, GVariant **variant) |
255 | { |
256 | *variant = g_variant_new_string (value); |
257 | return TRUE; |
258 | @@ -744,3 +843,34 @@ |
259 | free (edgeString); |
260 | return TRUE; |
261 | } |
262 | + |
263 | +void |
264 | +writeVariantToKey (GSettings *settings, |
265 | + const char *key, |
266 | + GVariant *value) |
267 | +{ |
268 | + g_settings_set_value (settings, key, value); |
269 | +} |
270 | + |
271 | +CCSContext * |
272 | +ccsGSettingsBackendGetContext (CCSBackend *backend) |
273 | +{ |
274 | + return (*(GET_INTERFACE (CCSGSettingsBackendInterface, backend))->gsettingsBackendGetContext) (backend); |
275 | +} |
276 | + |
277 | + |
278 | +void |
279 | +ccsGSettingsBackendConnectToChangedSignal (CCSBackend *backend, |
280 | + GObject *object) |
281 | +{ |
282 | + (*(GET_INTERFACE (CCSGSettingsBackendInterface, backend))->gsettingsBackendConnectToChangedSignal) (backend, object); |
283 | +} |
284 | + |
285 | +GSettings * |
286 | +ccsGSettingsGetSettingsObjectForPluginWithPath (CCSBackend *backend, |
287 | + const char *plugin, |
288 | + const char *path, |
289 | + CCSContext *context) |
290 | +{ |
291 | + return (*(GET_INTERFACE (CCSGSettingsBackendInterface, backend))->gsettingsBackendGetSettingsObjectForPluginWithPath) (backend, plugin, path, context); |
292 | +} |
293 | |
294 | === modified file 'compizconfig/gsettings/gsettings_backend_shared/gsettings_util.h' |
295 | --- compizconfig/gsettings/gsettings_backend_shared/gsettings_util.h 2012-07-21 20:44:19 +0000 |
296 | +++ compizconfig/gsettings/gsettings_backend_shared/gsettings_util.h 2012-07-21 20:44:20 +0000 |
297 | @@ -1,10 +1,38 @@ |
298 | #ifndef _COMPIZ_GSETTINGS_UTIL_H |
299 | #define _COMPIZ_GSETTINGS_UTIL_H |
300 | |
301 | +#include <ccs.h> |
302 | +#include <ccs-backend.h> |
303 | + |
304 | +COMPIZCONFIG_BEGIN_DECLS |
305 | + |
306 | #include <glib.h> |
307 | #include <glib-object.h> |
308 | #include <gio/gio.h> |
309 | -#include <ccs.h> |
310 | + |
311 | +typedef struct _CCSGSettingsBackendPrivate CCSGettingsBackendPrivate; |
312 | +typedef struct _CCSGSettingsBackendInterface CCSGSettingsBackendInterface; |
313 | + |
314 | +typedef CCSContext * (*CCSGSettingsBackendGetContext) (CCSBackend *); |
315 | +typedef void (*CCSGSettingsBackendConnectToChangedSignal) (CCSBackend *, GObject *); |
316 | +typedef GSettings * (*CCSGSettingsBackendGetSettingsObjectForPluginWithPath) (CCSBackend *backend, |
317 | + const char *plugin, |
318 | + const char *path, |
319 | + CCSContext *context); |
320 | + |
321 | +struct _CCSGSettingsBackendInterface |
322 | +{ |
323 | + CCSGSettingsBackendGetContext gsettingsBackendGetContext; |
324 | + CCSGSettingsBackendConnectToChangedSignal gsettingsBackendConnectToChangedSignal; |
325 | + CCSGSettingsBackendGetSettingsObjectForPluginWithPath gsettingsBackendGetSettingsObjectForPluginWithPath; |
326 | +}; |
327 | + |
328 | +struct _CCSGSettingsBackendPrivate |
329 | +{ |
330 | + CCSContext *context; |
331 | +}; |
332 | + |
333 | +unsigned int ccsCCSGSettingsBackendInterfaceGetType (); |
334 | |
335 | gchar * |
336 | getSchemaNameForPlugin (const char *plugin); |
337 | @@ -57,6 +85,20 @@ |
338 | CCSSetting * |
339 | attemptToFindCCSSettingFromLossyName (CCSSettingList settingList, const gchar *lossyName, CCSSettingType type); |
340 | |
341 | +Bool |
342 | +findSettingAndPluginToUpdateFromPath (GSettings *settings, |
343 | + const char *path, |
344 | + const gchar *keyName, |
345 | + CCSContext *context, |
346 | + CCSPlugin **plugin, |
347 | + CCSSetting **setting, |
348 | + char **uncleanKeyName); |
349 | + |
350 | +Bool updateSettingWithGSettingsKeyName (CCSBackend *backend, |
351 | + GSettings *settings, |
352 | + gchar *keyName, |
353 | + CCSBackendUpdateFunc updateSetting); |
354 | + |
355 | GList * |
356 | variantTypeToPossibleSettingType (const gchar *vt); |
357 | |
358 | @@ -73,7 +115,7 @@ |
359 | checkReadVariantIsValid (GVariant *gsettingsValue, CCSSettingType type, const gchar *pathName); |
360 | |
361 | GVariant * |
362 | -getVariantAtKey (GSettings *settings, char *key, const char *pathName, CCSSettingType type); |
363 | +getVariantAtKey (GSettings *settings, const char *key, const char *pathName, CCSSettingType type); |
364 | |
365 | const char * readStringFromVariant (GVariant *gsettingsValue); |
366 | |
367 | @@ -99,7 +141,7 @@ |
368 | CCSSettingType listType, |
369 | GVariant **gsettingsValue); |
370 | |
371 | -Bool writeStringToVariant (char *value, GVariant **variant); |
372 | +Bool writeStringToVariant (const char *value, GVariant **variant); |
373 | |
374 | Bool writeFloatToVariant (float value, GVariant **variant); |
375 | |
376 | @@ -115,4 +157,22 @@ |
377 | |
378 | Bool writeEdgeToVariant (unsigned int edges, GVariant **variant); |
379 | |
380 | +void writeVariantToKey (GSettings *settings, |
381 | + const char *key, |
382 | + GVariant *value); |
383 | + |
384 | +CCSContext * |
385 | +ccsGSettingsBackendGetContext (CCSBackend *backend); |
386 | + |
387 | +void |
388 | +ccsGSettingsBackendConnectToChangedSignal (CCSBackend *backend, GObject *object); |
389 | + |
390 | +GSettings * |
391 | +ccsGSettingsGetSettingsObjectForPluginWithPath (CCSBackend *backend, |
392 | + const char *plugin, |
393 | + const char *path, |
394 | + CCSContext *context); |
395 | + |
396 | +COMPIZCONFIG_END_DECLS |
397 | + |
398 | #endif |
399 | |
400 | === modified file 'compizconfig/gsettings/src/gconf-integration.c' |
401 | --- compizconfig/gsettings/src/gconf-integration.c 2012-07-21 20:44:19 +0000 |
402 | +++ compizconfig/gsettings/src/gconf-integration.c 2012-07-21 20:44:20 +0000 |
403 | @@ -537,7 +537,8 @@ |
404 | } |
405 | |
406 | Bool |
407 | -readGConfIntegratedOption (CCSContext *context, |
408 | +readGConfIntegratedOption (CCSBackend *backend, |
409 | + CCSContext *context, |
410 | CCSSetting *setting, |
411 | int index) |
412 | { |
413 | @@ -545,7 +546,7 @@ |
414 | GError *err = NULL; |
415 | Bool ret = FALSE; |
416 | |
417 | - ret = readOption (setting); |
418 | + ret = readOption (backend, setting); |
419 | |
420 | gconfValue = gconf_client_get (client, |
421 | specialOptions[index].gnomeName, |
422 | @@ -765,7 +766,8 @@ |
423 | } |
424 | |
425 | void |
426 | -writeGConfIntegratedOption (CCSContext *context, |
427 | +writeGConfIntegratedOption (CCSBackend *backend, |
428 | + CCSContext *context, |
429 | CCSSetting *setting, |
430 | int index) |
431 | { |
432 | |
433 | === modified file 'compizconfig/gsettings/src/gsettings.c' |
434 | --- compizconfig/gsettings/src/gsettings.c 2012-07-21 20:44:19 +0000 |
435 | +++ compizconfig/gsettings/src/gsettings.c 2012-07-21 20:44:20 +0000 |
436 | @@ -46,15 +46,20 @@ |
437 | |
438 | char *currentProfile = NULL; |
439 | |
440 | +/* This will need to be rempved */ |
441 | +CCSContext *storedContext = NULL; |
442 | + |
443 | /* some forward declarations */ |
444 | -static void writeIntegratedOption (CCSContext *context, |
445 | +static void writeIntegratedOption (CCSBackend *backend, |
446 | + CCSContext *context, |
447 | CCSSetting *setting, |
448 | int index); |
449 | |
450 | static GSettings * |
451 | -getSettingsObjectForPluginWithPath (const char *plugin, |
452 | - const char *path, |
453 | - CCSContext *context) |
454 | +ccsGSettingsBackendGetSettingsObjectForPluginWithPathDefault (CCSBackend *backend, |
455 | + const char *plugin, |
456 | + const char *path, |
457 | + CCSContext *context) |
458 | { |
459 | GSettings *settingsObj = NULL; |
460 | gchar *schemaName = getSchemaNameForPlugin (plugin); |
461 | @@ -74,7 +79,7 @@ |
462 | |
463 | settingsObj = g_settings_new_with_path (schemaName, path); |
464 | |
465 | - g_signal_connect (G_OBJECT (settingsObj), "changed", (GCallback) valueChanged, (gpointer) context); |
466 | + ccsGSettingsBackendConnectToChangedSignal (backend, G_OBJECT (settingsObj)); |
467 | |
468 | settingsList = g_list_append (settingsList, (void *) settingsObj); |
469 | |
470 | @@ -104,14 +109,15 @@ |
471 | } |
472 | |
473 | static GSettings * |
474 | -getSettingsObjectForCCSSetting (CCSSetting *setting) |
475 | +getSettingsObjectForCCSSetting (CCSBackend *backend, CCSSetting *setting) |
476 | { |
477 | GSettings *ret = NULL; |
478 | gchar *pathName = makeSettingPath (setting); |
479 | |
480 | - ret = getSettingsObjectForPluginWithPath (ccsPluginGetName (ccsSettingGetParent (setting)), |
481 | - pathName, |
482 | - ccsPluginGetContext (ccsSettingGetParent (setting))); |
483 | + ret = ccsGSettingsGetSettingsObjectForPluginWithPath (backend, |
484 | + ccsPluginGetName (ccsSettingGetParent (setting)), |
485 | + pathName, |
486 | + ccsPluginGetContext (ccsSettingGetParent (setting))); |
487 | |
488 | g_free (pathName); |
489 | return ret; |
490 | @@ -129,113 +135,57 @@ |
491 | } |
492 | |
493 | static void |
494 | +updateSetting (CCSBackend *backend, CCSContext *context, CCSPlugin *plugin, CCSSetting *setting) |
495 | +{ |
496 | + int index; |
497 | + |
498 | + readInit (backend, context); |
499 | + if (!readOption (backend, setting)) |
500 | + { |
501 | + ccsResetToDefault (setting, TRUE); |
502 | + } |
503 | + |
504 | + if (ccsGetIntegrationEnabled (context) && |
505 | + isIntegratedOption (setting, &index)) |
506 | + { |
507 | + writeInit (backend, context); |
508 | + writeIntegratedOption (backend, context, setting, index); |
509 | + } |
510 | +} |
511 | + |
512 | +static void |
513 | valueChanged (GSettings *settings, |
514 | gchar *keyName, |
515 | gpointer user_data) |
516 | { |
517 | - CCSContext *context = (CCSContext *)user_data; |
518 | - char *uncleanKeyName; |
519 | - char *path, *pathOrig; |
520 | - char *pluginName; |
521 | - int index; |
522 | - unsigned int screenNum; |
523 | - CCSPlugin *plugin; |
524 | - CCSSetting *setting; |
525 | - |
526 | - g_object_get (G_OBJECT (settings), "path", &pathOrig, NULL); |
527 | - |
528 | - path = pathOrig; |
529 | - |
530 | - if (!decomposeGSettingsPath (path, &pluginName, &screenNum)) |
531 | - { |
532 | - g_free (pathOrig); |
533 | - return; |
534 | - } |
535 | - |
536 | - plugin = ccsFindPlugin (context, pluginName); |
537 | - |
538 | - uncleanKeyName = translateKeyForCCS (keyName); |
539 | - |
540 | - setting = ccsFindSetting (plugin, uncleanKeyName); |
541 | - if (!setting) |
542 | - { |
543 | - /* Couldn't find setting straight off the bat, |
544 | - * try and find the best match */ |
545 | - GVariant *value = g_settings_get_value (settings, keyName); |
546 | - |
547 | - if (value) |
548 | - { |
549 | - GList *possibleSettingTypes = variantTypeToPossibleSettingType (g_variant_get_type_string (value)); |
550 | - GList *iter = possibleSettingTypes; |
551 | - |
552 | - while (iter) |
553 | - { |
554 | - setting = attemptToFindCCSSettingFromLossyName (ccsGetPluginSettings (plugin), |
555 | - keyName, |
556 | - (CCSSettingType) GPOINTER_TO_INT (iter->data)); |
557 | - |
558 | - if (setting) |
559 | - break; |
560 | - |
561 | - iter = iter->next; |
562 | - } |
563 | - |
564 | - g_list_free (possibleSettingTypes); |
565 | - g_variant_unref (value); |
566 | - } |
567 | - |
568 | - /* We hit a situation where either the key stored in GSettings couldn't be |
569 | - * matched at all to a key in the xml file, or where there were multiple matches. |
570 | - * Unfortunately, there isn't much we can do about this, other than try |
571 | - * and warn the user and bail out. It just means that if the key was updated |
572 | - * externally we won't know about the change until the next reload of settings */ |
573 | - if (!setting) |
574 | - { |
575 | - ccsWarning ("Unable to find setting %s, for path %s", uncleanKeyName, path); |
576 | - g_free (pluginName); |
577 | - free (uncleanKeyName); |
578 | - g_free (pathOrig); |
579 | - return; |
580 | - } |
581 | - } |
582 | - |
583 | - readInit (NULL, context); |
584 | - if (!readOption (setting)) |
585 | - { |
586 | - ccsResetToDefault (setting, TRUE); |
587 | - } |
588 | - |
589 | - if (ccsGetIntegrationEnabled (context) && |
590 | - isIntegratedOption (setting, &index)) |
591 | - { |
592 | - writeInit (NULL, context); |
593 | - writeIntegratedOption (context, setting, index); |
594 | - } |
595 | - |
596 | - g_free (pluginName); |
597 | - free (uncleanKeyName); |
598 | - g_free (pathOrig); |
599 | + CCSBackend *backend = (CCSBackend *)user_data; |
600 | + |
601 | + updateSettingWithGSettingsKeyName (backend, settings, keyName, updateSetting); |
602 | } |
603 | |
604 | static Bool |
605 | -readIntegratedOption (CCSContext *context, |
606 | +readIntegratedOption (CCSBackend *backend, |
607 | + CCSContext *context, |
608 | CCSSetting *setting, |
609 | int index) |
610 | { |
611 | #ifdef USE_GCONF |
612 | - return readGConfIntegratedOption (context, setting, index); |
613 | + return readGConfIntegratedOption (backend, context, setting, index); |
614 | #else |
615 | return FALSE; |
616 | #endif |
617 | } |
618 | |
619 | static GVariant * |
620 | -getVariantForCCSSetting (CCSSetting *setting) |
621 | +getVariantForCCSSetting (CCSBackend *backend, CCSSetting *setting) |
622 | { |
623 | - GSettings *settings = getSettingsObjectForCCSSetting (setting); |
624 | + GSettings *settings = getSettingsObjectForCCSSetting (backend, setting); |
625 | char *cleanSettingName = getNameForCCSSetting (setting); |
626 | gchar *pathName = makeSettingPath (setting); |
627 | - GVariant *gsettingsValue = getVariantAtKey (settings, cleanSettingName, pathName, ccsSettingGetType (setting)); |
628 | + GVariant *gsettingsValue = getVariantAtKey (settings, |
629 | + cleanSettingName, |
630 | + pathName, |
631 | + ccsSettingGetType (setting)); |
632 | |
633 | free (cleanSettingName); |
634 | free (pathName); |
635 | @@ -243,7 +193,7 @@ |
636 | } |
637 | |
638 | Bool |
639 | -readOption (CCSSetting * setting) |
640 | +readOption (CCSBackend *backend, CCSSetting * setting) |
641 | { |
642 | Bool ret = FALSE; |
643 | GVariant *gsettingsValue = NULL; |
644 | @@ -259,7 +209,7 @@ |
645 | return FALSE; |
646 | } |
647 | |
648 | - gsettingsValue = getVariantForCCSSetting (setting); |
649 | + gsettingsValue = getVariantForCCSSetting (backend, setting); |
650 | |
651 | switch (ccsSettingGetType (setting)) |
652 | { |
653 | @@ -397,21 +347,22 @@ |
654 | } |
655 | |
656 | static void |
657 | -writeIntegratedOption (CCSContext *context, |
658 | +writeIntegratedOption (CCSBackend *backend, |
659 | + CCSContext *context, |
660 | CCSSetting *setting, |
661 | int index) |
662 | { |
663 | #ifdef USE_GCONF |
664 | - writeGConfIntegratedOption (context, setting, index); |
665 | + writeGConfIntegratedOption (backend, context, setting, index); |
666 | #endif |
667 | |
668 | return; |
669 | } |
670 | |
671 | static void |
672 | -resetOptionToDefault (CCSSetting * setting) |
673 | +resetOptionToDefault (CCSBackend *backend, CCSSetting * setting) |
674 | { |
675 | - GSettings *settings = getSettingsObjectForCCSSetting (setting); |
676 | + GSettings *settings = getSettingsObjectForCCSSetting (backend, setting); |
677 | |
678 | char *cleanSettingName = translateKeyForGSettings (ccsSettingGetName (setting)); |
679 | |
680 | @@ -421,9 +372,9 @@ |
681 | } |
682 | |
683 | void |
684 | -writeOption (CCSSetting * setting) |
685 | +writeOption (CCSBackend *backend, CCSSetting * setting) |
686 | { |
687 | - GSettings *settings = getSettingsObjectForCCSSetting (setting); |
688 | + GSettings *settings = getSettingsObjectForCCSSetting (backend, setting); |
689 | char *cleanSettingName = translateKeyForGSettings (ccsSettingGetName (setting)); |
690 | GVariant *gsettingsValue = NULL; |
691 | Bool success = FALSE; |
692 | @@ -447,6 +398,7 @@ |
693 | success = writeStringToVariant (value, &gsettingsValue); |
694 | } |
695 | } |
696 | + break; |
697 | case TypeFloat: |
698 | { |
699 | float value; |
700 | @@ -525,7 +477,6 @@ |
701 | break; |
702 | case TypeList: |
703 | { |
704 | - GVariant *value = NULL; |
705 | CCSSettingValueList list = NULL; |
706 | |
707 | if (!ccsGetList (setting, &list)) |
708 | @@ -533,7 +484,7 @@ |
709 | |
710 | success = writeListValue (list, |
711 | ccsSettingGetInfo (setting)->forList.listType, |
712 | - &value); |
713 | + &gsettingsValue); |
714 | } |
715 | break; |
716 | default: |
717 | @@ -546,7 +497,7 @@ |
718 | { |
719 | /* g_settings_set_value will consume the reference |
720 | * so there is no need to unref value here */ |
721 | - g_settings_set_value (settings, cleanSettingName, gsettingsValue); |
722 | + writeVariantToKey (settings, cleanSettingName, gsettingsValue); |
723 | } |
724 | |
725 | free (cleanSettingName); |
726 | @@ -644,6 +595,24 @@ |
727 | } |
728 | } |
729 | |
730 | +static CCSContext * |
731 | +ccsGSettingsBackendGetContextDefault (CCSBackend *backend) |
732 | +{ |
733 | + return storedContext; |
734 | +} |
735 | + |
736 | +static void |
737 | +ccsGSettingsBackendConnectToValueChangedSignalDefault (CCSBackend *backend, GObject *object) |
738 | +{ |
739 | + g_signal_connect (object, "changed", (GCallback) valueChanged, (gpointer) backend); |
740 | +} |
741 | + |
742 | +static CCSGSettingsBackendInterface gsettingsAdditionalDefaultInterface = { |
743 | + ccsGSettingsBackendGetContextDefault, |
744 | + ccsGSettingsBackendConnectToValueChangedSignalDefault, |
745 | + ccsGSettingsBackendGetSettingsObjectForPluginWithPathDefault |
746 | +}; |
747 | + |
748 | static Bool |
749 | initBackend (CCSBackend *backend, CCSContext * context) |
750 | { |
751 | @@ -663,6 +632,10 @@ |
752 | |
753 | g_free (currentProfilePath); |
754 | |
755 | + storedContext = context; |
756 | + |
757 | + ccsObjectAddInterface (backend, (CCSInterface *) &gsettingsAdditionalDefaultInterface, GET_INTERFACE_TYPE (CCSGSettingsBackendInterface)); |
758 | + |
759 | return TRUE; |
760 | } |
761 | |
762 | @@ -690,6 +663,8 @@ |
763 | l = g_list_next (l); |
764 | } |
765 | |
766 | + settingsList = NULL; |
767 | + |
768 | if (currentProfileSettings) |
769 | { |
770 | g_object_unref (currentProfileSettings); |
771 | @@ -698,6 +673,8 @@ |
772 | |
773 | g_object_unref (G_OBJECT (compizconfigSettings)); |
774 | |
775 | + compizconfigSettings = NULL; |
776 | + |
777 | processEvents (backend, 0); |
778 | return TRUE; |
779 | } |
780 | @@ -719,10 +696,10 @@ |
781 | if (ccsGetIntegrationEnabled (context) && |
782 | isIntegratedOption (setting, &index)) |
783 | { |
784 | - status = readIntegratedOption (context, setting, index); |
785 | + status = readIntegratedOption (backend, context, setting, index); |
786 | } |
787 | else |
788 | - status = readOption (setting); |
789 | + status = readOption (backend, setting); |
790 | |
791 | if (!status) |
792 | ccsResetToDefault (setting, TRUE); |
793 | @@ -744,14 +721,14 @@ |
794 | if (ccsGetIntegrationEnabled (context) && |
795 | isIntegratedOption (setting, &index)) |
796 | { |
797 | - writeIntegratedOption (context, setting, index); |
798 | + writeIntegratedOption (backend, context, setting, index); |
799 | } |
800 | else if (ccsSettingGetIsDefault (setting)) |
801 | { |
802 | - resetOptionToDefault (setting); |
803 | + resetOptionToDefault (backend, setting); |
804 | } |
805 | else |
806 | - writeOption (setting); |
807 | + writeOption (backend, setting); |
808 | |
809 | } |
810 | |
811 | @@ -821,7 +798,7 @@ |
812 | GSettings *settings; |
813 | gchar *pathName = makeCompizPluginPath (currentProfile, plugin); |
814 | |
815 | - settings = getSettingsObjectForPluginWithPath (plugin, pathName, context); |
816 | + settings = ccsGSettingsGetSettingsObjectForPluginWithPath (backend, plugin, pathName, context); |
817 | g_free (pathName); |
818 | |
819 | /* The GSettings documentation says not to use this API |
820 | @@ -916,12 +893,15 @@ |
821 | writeInit, |
822 | writeSetting, |
823 | 0, |
824 | + updateSetting, |
825 | getSettingIsIntegrated, |
826 | getSettingIsReadOnly, |
827 | getExistingProfiles, |
828 | deleteProfile |
829 | }; |
830 | |
831 | + |
832 | + |
833 | CCSBackendInterface * |
834 | getBackendInfo (void) |
835 | { |
836 | |
837 | === modified file 'compizconfig/gsettings/src/gsettings.h' |
838 | --- compizconfig/gsettings/src/gsettings.h 2012-07-21 20:44:19 +0000 |
839 | +++ compizconfig/gsettings/src/gsettings.h 2012-07-21 20:44:20 +0000 |
840 | @@ -68,9 +68,9 @@ |
841 | |
842 | Bool readInit (CCSBackend *, CCSContext * context); |
843 | void readSetting (CCSBackend *, CCSContext * context, CCSSetting * setting); |
844 | -Bool readOption (CCSSetting * setting); |
845 | +Bool readOption (CCSBackend *backend, CCSSetting * setting); |
846 | Bool writeInit (CCSBackend *, CCSContext * context); |
847 | -void writeOption (CCSSetting *setting); |
848 | +void writeOption (CCSBackend *backend, CCSSetting *setting); |
849 | |
850 | #ifdef USE_GCONF |
851 | |
852 | @@ -106,12 +106,14 @@ |
853 | finiGConfClient (void); |
854 | |
855 | Bool |
856 | -readGConfIntegratedOption (CCSContext *context, |
857 | +readGConfIntegratedOption (CCSBackend *backend, |
858 | + CCSContext *context, |
859 | CCSSetting *setting, |
860 | int index); |
861 | |
862 | void |
863 | -writeGConfIntegratedOption (CCSContext *context, |
864 | +writeGConfIntegratedOption (CCSBackend *backend, |
865 | + CCSContext *context, |
866 | CCSSetting *setting, |
867 | int index); |
868 | |
869 | |
870 | === modified file 'compizconfig/gsettings/tests/CMakeLists.txt' |
871 | --- compizconfig/gsettings/tests/CMakeLists.txt 2012-07-21 20:44:19 +0000 |
872 | +++ compizconfig/gsettings/tests/CMakeLists.txt 2012-07-21 20:44:20 +0000 |
873 | @@ -1,10 +1,16 @@ |
874 | +include (CompizGSettings) |
875 | + |
876 | include_directories (${CMAKE_CURRENT_SOURCE_DIR} |
877 | + ${CMAKE_CURRENT_BINARY_DIR} |
878 | ${CMAKE_CURRENT_SOURCE_DIR}/../src |
879 | ${CMAKE_CURRENT_SOURCE_DIR}/../../libcompizconfig/tests |
880 | - ${CMAKE_CURRENT_SOURCE_DIR}/../../mocks/libcompizconfig) |
881 | + ${CMAKE_CURRENT_SOURCE_DIR}/../../mocks/libcompizconfig |
882 | + ${CMAKE_CURRENT_SOURCE_DIR}/../../tests) |
883 | |
884 | pkg_check_modules (COMPIZCONFIG_TEST_GSETTINGS libcompizconfig) |
885 | |
886 | +link_directories (${CMAKE_CURRENT_BINARY_DIR}/../../libcompizconfig/tests) |
887 | + |
888 | add_executable (compizconfig_test_gsettings |
889 | ${CMAKE_CURRENT_SOURCE_DIR}/gsettings_mocks.cpp |
890 | ${CMAKE_CURRENT_SOURCE_DIR}/test_gsettings_tests.cpp |
891 | @@ -12,7 +18,8 @@ |
892 | ${CMAKE_CURRENT_SOURCE_DIR}/gsettings_mocks.h |
893 | ${CMAKE_CURRENT_SOURCE_DIR}/test_gsettings_tests.h) |
894 | |
895 | -link_directories (${CMAKE_CURRENT_BINARY_DIR}/../../libcompizconfig/tests) |
896 | +add_executable (compizconfig_test_gsettings_conformance |
897 | + ${CMAKE_CURRENT_SOURCE_DIR}/test_gsettings_conformance.cpp) |
898 | |
899 | target_link_libraries (compizconfig_test_gsettings |
900 | gsettings_backend_shared |
901 | @@ -21,4 +28,27 @@ |
902 | ${GTEST_BOTH_LIBRARIES} |
903 | ${GMOCK_MAIN_LIBRARY}) |
904 | |
905 | +configure_file (${CMAKE_CURRENT_SOURCE_DIR}/backend-conformance-config.h.in |
906 | + ${CMAKE_CURRENT_BINARY_DIR}/backend-conformance-config.h) |
907 | + |
908 | +add_custom_command (OUTPUT ${CMAKE_BINARY_DIR}/generated/glib-2.0/schemas/org.compiz.mock.gschema.xml |
909 | + 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 |
910 | + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/org.compiz.mock.gschema.xml |
911 | + VERBATIM) |
912 | + |
913 | +add_custom_target (compiz_gsettings_mock_schema ALL |
914 | + DEPENDS ${CMAKE_BINARY_DIR}/generated/glib-2.0/schemas/org.compiz.mock.gschema.xml) |
915 | + |
916 | +add_gsettings_schema_to_recompilation_list (compiz_gsettings_mock_schema) |
917 | + |
918 | +target_link_libraries (compizconfig_test_gsettings_conformance |
919 | + gsettings_backend_shared |
920 | + compizconfig_ccs_setting_mock |
921 | + compizconfig_ccs_plugin_mock |
922 | + compizconfig_ccs_context_mock |
923 | + ${COMPIZCONFIG_TEST_GSETTINGS_LIBRARIES} |
924 | + ${GTEST_BOTH_LIBRARIES} |
925 | + ${GMOCK_MAIN_LIBRARY}) |
926 | + |
927 | compiz_discover_tests (compizconfig_test_gsettings) |
928 | +compiz_discover_tests (compizconfig_test_gsettings_conformance) |
929 | |
930 | === added file 'compizconfig/gsettings/tests/backend-conformance-config.h.in' |
931 | --- compizconfig/gsettings/tests/backend-conformance-config.h.in 1970-01-01 00:00:00 +0000 |
932 | +++ compizconfig/gsettings/tests/backend-conformance-config.h.in 2012-07-21 20:44:20 +0000 |
933 | @@ -0,0 +1,2 @@ |
934 | +#define BACKEND_BINARY_PATH "@CMAKE_BINARY_DIR@/compizconfig/gsettings" |
935 | +#define MOCK_SCHEMA_PATH "@CMAKE_BINARY_DIR@/generated/glib-2.0/schemas" |
936 | |
937 | === added file 'compizconfig/gsettings/tests/org.compiz.mock.gschema.xml' |
938 | --- compizconfig/gsettings/tests/org.compiz.mock.gschema.xml 1970-01-01 00:00:00 +0000 |
939 | +++ compizconfig/gsettings/tests/org.compiz.mock.gschema.xml 2012-07-21 20:44:20 +0000 |
940 | @@ -0,0 +1,50 @@ |
941 | +<?xml version="1.0"?> |
942 | +<schemalist> |
943 | + <schema id="org.compiz.mock" gettext-domain="compiz"> |
944 | + <key type="i" name="integer-setting"> |
945 | + <default>0</default> |
946 | + </key> |
947 | + <key type="b" name="boolean-setting"> |
948 | + <default>false</default> |
949 | + </key> |
950 | + <key type="d" name="float-setting"> |
951 | + <default>0.0</default> |
952 | + </key> |
953 | + <key type="s" name="string-setting"> |
954 | + <default>""</default> |
955 | + </key> |
956 | + <key type="s" name="match-setting"> |
957 | + <default>""</default> |
958 | + </key> |
959 | + <key type="b" name="bell-setting"> |
960 | + <default>false</default> |
961 | + </key> |
962 | + <key type="s" name="color-setting"> |
963 | + <default>""</default> |
964 | + </key> |
965 | + <key type="s" name="key-setting"> |
966 | + <default>""</default> |
967 | + </key> |
968 | + <key type="s" name="button-setting"> |
969 | + <default>""</default> |
970 | + </key> |
971 | + <key type="s" name="edge-setting"> |
972 | + <default>""</default> |
973 | + </key> |
974 | + <key type="ai" name="int-list-setting"> |
975 | + <default>[0]</default> |
976 | + </key> |
977 | + <key type="ad" name="float-list-setting"> |
978 | + <default>[0.0]</default> |
979 | + </key> |
980 | + <key type="ab" name="bool-list-setting"> |
981 | + <default>[true]</default> |
982 | + </key> |
983 | + <key type="as" name="string-list-setting"> |
984 | + <default>[""]</default> |
985 | + </key> |
986 | + <key type="as" name="color-list-setting"> |
987 | + <default>[""]</default> |
988 | + </key> |
989 | + </schema> |
990 | +</schemalist> |
991 | |
992 | === added file 'compizconfig/gsettings/tests/test_gsettings_conformance.cpp' |
993 | --- compizconfig/gsettings/tests/test_gsettings_conformance.cpp 1970-01-01 00:00:00 +0000 |
994 | +++ compizconfig/gsettings/tests/test_gsettings_conformance.cpp 2012-07-21 20:44:20 +0000 |
995 | @@ -0,0 +1,431 @@ |
996 | +#include <gtest/gtest.h> |
997 | +#include <gmock/gmock.h> |
998 | + |
999 | +#include <gsettings_util.h> |
1000 | + |
1001 | +#include <gio/gio.h> |
1002 | + |
1003 | +#include "backend-conformance-config.h" |
1004 | + |
1005 | +#include <ccs.h> |
1006 | +#include <compizconfig_backend_concept_test.h> |
1007 | + |
1008 | +#include <iostream> |
1009 | + |
1010 | +using ::testing::AtLeast; |
1011 | +using ::testing::Pointee; |
1012 | +using ::testing::ReturnNull; |
1013 | + |
1014 | +namespace |
1015 | +{ |
1016 | +const std::string MOCK_SCHEMA ("org.compiz.mock"); |
1017 | +const std::string MOCK_PATH (MOCK_SCHEMA_PATH); |
1018 | +} |
1019 | + |
1020 | +class CCSGSettingsBackendEnv : |
1021 | + public CCSBackendConceptTestEnvironmentInterface |
1022 | +{ |
1023 | + public: |
1024 | + |
1025 | + CCSGSettingsBackendEnv () : |
1026 | + pluginToMatch ("mock") |
1027 | + { |
1028 | + g_type_init (); |
1029 | + } |
1030 | + |
1031 | + /* A wrapper to prevent signals from being added */ |
1032 | + static void connectToSignalWrapper (CCSBackend *backend, GObject *object) |
1033 | + { |
1034 | + }; |
1035 | + |
1036 | + CCSBackend * SetUp (CCSContext *context, CCSContextGMock *gmockContext) |
1037 | + { |
1038 | + CCSBackendInterface *interface = NULL; |
1039 | + Bool fallback = FALSE; |
1040 | + |
1041 | + g_setenv ("GSETTINGS_SCHEMA_DIR", MOCK_PATH.c_str (), true); |
1042 | + g_setenv ("GSETTINGS_BACKEND", "memory", true); |
1043 | + g_setenv ("LIBCOMPIZCONFIG_BACKEND_PATH", BACKEND_BINARY_PATH, true); |
1044 | + |
1045 | + mContext = context; |
1046 | + |
1047 | + std::string path ("gsettings"); |
1048 | + |
1049 | + void *dlhand = ccsOpenBackend (path.c_str (), &interface, &fallback); |
1050 | + |
1051 | + EXPECT_FALSE (fallback); |
1052 | + EXPECT_TRUE (dlhand); |
1053 | + |
1054 | + mGSettingsBackend = ccsBackendNewWithInterface (mContext, interface, dlhand); |
1055 | + mBackend = ccsBackendWithCapabilitiesWrapBackend (&ccsDefaultInterfaceTable, mGSettingsBackend); |
1056 | + |
1057 | + CCSBackendInitFunc backendInit = (GET_INTERFACE (CCSBackendInterface, mBackend))->backendInit; |
1058 | + |
1059 | + if (backendInit) |
1060 | + (*backendInit) ((CCSBackend *) mBackend, mContext); |
1061 | + |
1062 | + overloadedInterface = *(GET_INTERFACE (CCSGSettingsBackendInterface, mGSettingsBackend)); |
1063 | + overloadedInterface.gsettingsBackendConnectToChangedSignal = CCSGSettingsBackendEnv::connectToSignalWrapper; |
1064 | + |
1065 | + ccsObjectRemoveInterface (mGSettingsBackend, GET_INTERFACE_TYPE (CCSGSettingsBackendInterface)); |
1066 | + ccsObjectAddInterface (mGSettingsBackend, (CCSInterface *) &overloadedInterface, GET_INTERFACE_TYPE (CCSGSettingsBackendInterface)); |
1067 | + |
1068 | + mSettings = ccsGSettingsGetSettingsObjectForPluginWithPath (mGSettingsBackend, "mock", makeCompizPluginPath (profileName.c_str (), "mock"), mContext); |
1069 | + |
1070 | + ON_CALL (*gmockContext, getProfile ()).WillByDefault (Return (profileName.c_str ())); |
1071 | + |
1072 | + return (CCSBackend *) mBackend; |
1073 | + } |
1074 | + |
1075 | + void TearDown (CCSBackend *) |
1076 | + { |
1077 | + g_unsetenv ("GSETTINGS_SCHEMA_DIR"); |
1078 | + g_unsetenv ("GSETTINGS_BACKEND"); |
1079 | + g_unsetenv ("LIBCOMPIZCONFIG_BACKEND_PATH"); |
1080 | + |
1081 | + ccsFreeBackendWithCapabilities (mBackend); |
1082 | + } |
1083 | + |
1084 | + void PreWrite (CCSContextGMock *gmockContext, |
1085 | + CCSPluginGMock *gmockPlugin, |
1086 | + CCSSettingGMock *gmockSetting, |
1087 | + CCSSettingType type) |
1088 | + { |
1089 | + EXPECT_CALL (*gmockContext, getIntegrationEnabled ()).WillRepeatedly (Return (FALSE)); |
1090 | + EXPECT_CALL (*gmockPlugin, getContext ()).Times (AtLeast (1)); |
1091 | + EXPECT_CALL (*gmockPlugin, getName ()).Times (AtLeast (1)); |
1092 | + EXPECT_CALL (*gmockSetting, getType ()).Times (AtLeast (1)); |
1093 | + EXPECT_CALL (*gmockSetting, getName ()).Times (AtLeast (1)); |
1094 | + EXPECT_CALL (*gmockSetting, getParent ()).Times (AtLeast (1)); |
1095 | + EXPECT_CALL (*gmockSetting, getIsDefault ()).WillRepeatedly (Return (FALSE)); |
1096 | + } |
1097 | + |
1098 | + void PostWrite (CCSContextGMock *gmockContext, |
1099 | + CCSPluginGMock *gmockPlugin, |
1100 | + CCSSettingGMock *gmockSetting, |
1101 | + CCSSettingType type) {} |
1102 | + |
1103 | + void WriteBoolAtKey (const std::string &plugin, |
1104 | + const std::string &key, |
1105 | + const VariantTypes &value) |
1106 | + { |
1107 | + GVariant *variant = NULL; |
1108 | + if (writeBoolToVariant (boolToBool (boost::get <bool> (value)), &variant)) |
1109 | + writeVariantToKey (mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant); |
1110 | + else |
1111 | + throw std::exception (); |
1112 | + } |
1113 | + |
1114 | + void WriteIntegerAtKey (const std::string &plugin, |
1115 | + const std::string &key, |
1116 | + const VariantTypes &value) |
1117 | + { |
1118 | + GVariant *variant = NULL; |
1119 | + if (writeIntToVariant (boost::get <int> (value), &variant)) |
1120 | + writeVariantToKey (mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant); |
1121 | + else |
1122 | + throw std::exception (); |
1123 | + } |
1124 | + |
1125 | + void WriteFloatAtKey (const std::string &plugin, |
1126 | + const std::string &key, |
1127 | + const VariantTypes &value) |
1128 | + { |
1129 | + GVariant *variant = NULL; |
1130 | + if (writeFloatToVariant (boost::get <float> (value), &variant)) |
1131 | + writeVariantToKey (mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant); |
1132 | + else |
1133 | + throw std::exception (); |
1134 | + } |
1135 | + |
1136 | + void WriteStringAtKey (const std::string &plugin, |
1137 | + const std::string &key, |
1138 | + const VariantTypes &value) |
1139 | + { |
1140 | + GVariant *variant = NULL; |
1141 | + if (writeStringToVariant (boost::get <const char *> (value), &variant)) |
1142 | + writeVariantToKey (mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant); |
1143 | + else |
1144 | + throw std::exception (); |
1145 | + } |
1146 | + |
1147 | + void WriteColorAtKey (const std::string &plugin, |
1148 | + const std::string &key, |
1149 | + const VariantTypes &value) |
1150 | + { |
1151 | + GVariant *variant = NULL; |
1152 | + if (writeColorToVariant (boost::get <CCSSettingColorValue> (value), &variant)) |
1153 | + writeVariantToKey (mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant); |
1154 | + else |
1155 | + throw std::exception (); |
1156 | + } |
1157 | + |
1158 | + void WriteKeyAtKey (const std::string &plugin, |
1159 | + const std::string &key, |
1160 | + const VariantTypes &value) |
1161 | + { |
1162 | + GVariant *variant = NULL; |
1163 | + if (writeKeyToVariant (boost::get <CCSSettingKeyValue> (value), &variant)) |
1164 | + writeVariantToKey (mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant); |
1165 | + else |
1166 | + throw std::exception (); |
1167 | + } |
1168 | + |
1169 | + void WriteButtonAtKey (const std::string &plugin, |
1170 | + const std::string &key, |
1171 | + const VariantTypes &value) |
1172 | + { |
1173 | + GVariant *variant = NULL; |
1174 | + if (writeButtonToVariant (boost::get <CCSSettingButtonValue> (value), &variant)) |
1175 | + writeVariantToKey (mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant); |
1176 | + else |
1177 | + throw std::exception (); |
1178 | + } |
1179 | + |
1180 | + void WriteEdgeAtKey (const std::string &plugin, |
1181 | + const std::string &key, |
1182 | + const VariantTypes &value) |
1183 | + { |
1184 | + GVariant *variant = NULL; |
1185 | + if (writeEdgeToVariant (boost::get <unsigned int> (value), &variant)) |
1186 | + writeVariantToKey (mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant); |
1187 | + else |
1188 | + throw std::exception (); |
1189 | + } |
1190 | + |
1191 | + void WriteMatchAtKey (const std::string &plugin, |
1192 | + const std::string &key, |
1193 | + const VariantTypes &value) |
1194 | + { |
1195 | + GVariant *variant = NULL; |
1196 | + if (writeStringToVariant (boost::get <const char *> (value), &variant)) |
1197 | + writeVariantToKey (mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant); |
1198 | + else |
1199 | + throw std::exception (); |
1200 | + } |
1201 | + |
1202 | + void WriteBellAtKey (const std::string &plugin, |
1203 | + const std::string &key, |
1204 | + const VariantTypes &value) |
1205 | + { |
1206 | + GVariant *variant = NULL; |
1207 | + if (writeBoolToVariant (boolToBool (boost::get <bool> (value)), &variant)) |
1208 | + writeVariantToKey (mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant); |
1209 | + else |
1210 | + throw std::exception (); |
1211 | + } |
1212 | + |
1213 | + void WriteListAtKey (const std::string &plugin, |
1214 | + const std::string &key, |
1215 | + const VariantTypes &value) |
1216 | + { |
1217 | + GVariant *variant = NULL; |
1218 | + |
1219 | + const CCSListWrapper::Ptr &lw (boost::get <CCSListWrapper::Ptr> (value)); |
1220 | + |
1221 | + if (writeListValue (*lw, lw->type (), &variant)) |
1222 | + writeVariantToKey (mSettings, CharacterWrapper (translateKeyForGSettings (key.c_str ())), variant); |
1223 | + else |
1224 | + throw std::exception (); |
1225 | + } |
1226 | + |
1227 | + void PreRead (CCSContextGMock *gmockContext, |
1228 | + CCSPluginGMock *gmockPlugin, |
1229 | + CCSSettingGMock *gmockSetting, |
1230 | + CCSSettingType type) |
1231 | + { |
1232 | + EXPECT_CALL (*gmockContext, getIntegrationEnabled ()).WillOnce (Return (FALSE)); |
1233 | + EXPECT_CALL (*gmockPlugin, getContext ()).Times (AtLeast (1)); |
1234 | + EXPECT_CALL (*gmockPlugin, getName ()).Times (AtLeast (1)); |
1235 | + EXPECT_CALL (*gmockSetting, getType ()).Times (AtLeast (1)); |
1236 | + EXPECT_CALL (*gmockSetting, getName ()).Times (AtLeast (1)); |
1237 | + EXPECT_CALL (*gmockSetting, getParent ()).Times (AtLeast (1)); |
1238 | + EXPECT_CALL (*gmockSetting, isReadOnly ()).WillRepeatedly (Return (FALSE)); |
1239 | + |
1240 | + if (type == TypeList) |
1241 | + { |
1242 | + EXPECT_CALL (*gmockSetting, getInfo ()).Times (AtLeast (1)); |
1243 | + EXPECT_CALL (*gmockSetting, getDefaultValue ()).WillRepeatedly (ReturnNull ()); |
1244 | + } |
1245 | + } |
1246 | + |
1247 | + void PostRead (CCSContextGMock *gmockContext, |
1248 | + CCSPluginGMock *gmockPlugin, |
1249 | + CCSSettingGMock *gmockSetting, |
1250 | + CCSSettingType type) {} |
1251 | + |
1252 | + Bool ReadBoolAtKey (const std::string &plugin, |
1253 | + const std::string &key) |
1254 | + { |
1255 | + GVariant *variant = getVariantAtKey (mSettings, |
1256 | + CharacterWrapper (translateKeyForGSettings (key.c_str ())), |
1257 | + CharacterWrapper (makeCompizPluginPath (profileName.c_str (), plugin.c_str ())), |
1258 | + TypeBool); |
1259 | + return readBoolFromVariant (variant); |
1260 | + } |
1261 | + |
1262 | + int ReadIntegerAtKey (const std::string &plugin, |
1263 | + const std::string &key) |
1264 | + { |
1265 | + GVariant *variant = getVariantAtKey (mSettings, |
1266 | + CharacterWrapper (translateKeyForGSettings (key.c_str ())), |
1267 | + CharacterWrapper (makeCompizPluginPath (profileName.c_str (), plugin.c_str ())), |
1268 | + TypeInt); |
1269 | + return readIntFromVariant (variant); |
1270 | + } |
1271 | + |
1272 | + float ReadFloatAtKey (const std::string &plugin, |
1273 | + const std::string &key) |
1274 | + { |
1275 | + GVariant *variant = getVariantAtKey (mSettings, |
1276 | + CharacterWrapper (translateKeyForGSettings (key.c_str ())), |
1277 | + CharacterWrapper (makeCompizPluginPath (profileName.c_str (), plugin.c_str ())), |
1278 | + TypeFloat); |
1279 | + return readFloatFromVariant (variant); |
1280 | + } |
1281 | + |
1282 | + const char * ReadStringAtKey (const std::string &plugin, |
1283 | + const std::string &key) |
1284 | + { |
1285 | + GVariant *variant = getVariantAtKey (mSettings, |
1286 | + CharacterWrapper (translateKeyForGSettings (key.c_str ())), |
1287 | + CharacterWrapper (makeCompizPluginPath (profileName.c_str (), plugin.c_str ())), |
1288 | + TypeString); |
1289 | + return readStringFromVariant (variant); |
1290 | + } |
1291 | + |
1292 | + CCSSettingColorValue ReadColorAtKey (const std::string &plugin, |
1293 | + const std::string &key) |
1294 | + { |
1295 | + Bool success = FALSE; |
1296 | + GVariant *variant = getVariantAtKey (mSettings, |
1297 | + CharacterWrapper (translateKeyForGSettings (key.c_str ())), |
1298 | + CharacterWrapper (makeCompizPluginPath (profileName.c_str (), plugin.c_str ())), |
1299 | + TypeColor); |
1300 | + CCSSettingColorValue value = readColorFromVariant (variant, &success); |
1301 | + EXPECT_TRUE (success); |
1302 | + return value; |
1303 | + } |
1304 | + |
1305 | + CCSSettingKeyValue ReadKeyAtKey (const std::string &plugin, |
1306 | + const std::string &key) |
1307 | + { |
1308 | + Bool success = FALSE; |
1309 | + GVariant *variant = getVariantAtKey (mSettings, |
1310 | + CharacterWrapper (translateKeyForGSettings (key.c_str ())), |
1311 | + CharacterWrapper (makeCompizPluginPath (profileName.c_str (), plugin.c_str ())), |
1312 | + TypeKey); |
1313 | + CCSSettingKeyValue value = readKeyFromVariant (variant, &success); |
1314 | + EXPECT_TRUE (success); |
1315 | + return value; |
1316 | + } |
1317 | + |
1318 | + CCSSettingButtonValue ReadButtonAtKey (const std::string &plugin, |
1319 | + const std::string &key) |
1320 | + { |
1321 | + Bool success = FALSE; |
1322 | + GVariant *variant = getVariantAtKey (mSettings, |
1323 | + CharacterWrapper (translateKeyForGSettings (key.c_str ())), |
1324 | + CharacterWrapper (makeCompizPluginPath (profileName.c_str (), plugin.c_str ())), |
1325 | + TypeButton); |
1326 | + CCSSettingButtonValue value = readButtonFromVariant (variant, &success); |
1327 | + EXPECT_TRUE (success); |
1328 | + return value; |
1329 | + } |
1330 | + |
1331 | + unsigned int ReadEdgeAtKey (const std::string &plugin, |
1332 | + const std::string &key) |
1333 | + { |
1334 | + GVariant *variant = getVariantAtKey (mSettings, |
1335 | + CharacterWrapper (translateKeyForGSettings (key.c_str ())), |
1336 | + CharacterWrapper (makeCompizPluginPath (profileName.c_str (), plugin.c_str ())), |
1337 | + TypeEdge); |
1338 | + return readEdgeFromVariant (variant); |
1339 | + } |
1340 | + |
1341 | + const char * ReadMatchAtKey (const std::string &plugin, |
1342 | + const std::string &key) |
1343 | + { |
1344 | + GVariant *variant = getVariantAtKey (mSettings, |
1345 | + CharacterWrapper (translateKeyForGSettings (key.c_str ())), |
1346 | + CharacterWrapper (makeCompizPluginPath (profileName.c_str (), plugin.c_str ())), |
1347 | + TypeMatch); |
1348 | + return readStringFromVariant (variant); |
1349 | + } |
1350 | + |
1351 | + Bool ReadBellAtKey (const std::string &plugin, |
1352 | + const std::string &key) |
1353 | + { |
1354 | + GVariant *variant = getVariantAtKey (mSettings, |
1355 | + CharacterWrapper (translateKeyForGSettings (key.c_str ())), |
1356 | + CharacterWrapper (makeCompizPluginPath (profileName.c_str (), plugin.c_str ())), |
1357 | + TypeBell); |
1358 | + return readBoolFromVariant (variant); |
1359 | + } |
1360 | + |
1361 | + CCSSettingValueList ReadListAtKey (const std::string &plugin, |
1362 | + const std::string &key, |
1363 | + CCSSettingInfo *info) |
1364 | + { |
1365 | + GVariant *variant = getVariantAtKey (mSettings, |
1366 | + CharacterWrapper (translateKeyForGSettings (key.c_str ())), |
1367 | + CharacterWrapper (makeCompizPluginPath (profileName.c_str (), plugin.c_str ())), |
1368 | + TypeList); |
1369 | + return readListValue (variant, info->forList.listType); |
1370 | + } |
1371 | + |
1372 | + void PreUpdate (CCSContextGMock *gmockContext, |
1373 | + CCSPluginGMock *gmockPlugin, |
1374 | + CCSSettingGMock *gmockSetting, |
1375 | + CCSSettingType type) |
1376 | + { |
1377 | + EXPECT_CALL (*gmockContext, getIntegrationEnabled ()).WillOnce (Return (FALSE)); |
1378 | + EXPECT_CALL (*gmockPlugin, getContext ()).Times (AtLeast (1)); |
1379 | + EXPECT_CALL (*gmockPlugin, getName ()).Times (AtLeast (1)); |
1380 | + EXPECT_CALL (*gmockSetting, getType ()).Times (AtLeast (1)); |
1381 | + EXPECT_CALL (*gmockSetting, getName ()).Times (AtLeast (1)); |
1382 | + EXPECT_CALL (*gmockSetting, getParent ()).Times (AtLeast (1)); |
1383 | + EXPECT_CALL (*gmockSetting, isReadOnly ()).WillRepeatedly (Return (FALSE)); |
1384 | + |
1385 | + if (type == TypeList) |
1386 | + { |
1387 | + EXPECT_CALL (*gmockSetting, getInfo ()).Times (AtLeast (1)); |
1388 | + EXPECT_CALL (*gmockSetting, getDefaultValue ()).WillRepeatedly (ReturnNull ()); |
1389 | + } |
1390 | + |
1391 | + EXPECT_CALL (*gmockContext, getProfile ()); |
1392 | + } |
1393 | + |
1394 | + void PostUpdate (CCSContextGMock *gmockContext, |
1395 | + CCSPluginGMock *gmockPlugin, |
1396 | + CCSSettingGMock *gmockSetting, |
1397 | + CCSSettingType type) {} |
1398 | + |
1399 | + bool UpdateSettingAtKey (const std::string &plugin, |
1400 | + const std::string &setting) |
1401 | + { |
1402 | + CharacterWrapper keyName (translateKeyForGSettings (setting.c_str ())); |
1403 | + |
1404 | + if (updateSettingWithGSettingsKeyName (reinterpret_cast <CCSBackend *> (mGSettingsBackend), mSettings, keyName, ccsBackendUpdateSetting)) |
1405 | + return true; |
1406 | + |
1407 | + return false; |
1408 | + } |
1409 | + |
1410 | + private: |
1411 | + |
1412 | + GSettings *mSettings; |
1413 | + CCSContext *mContext; |
1414 | + CCSBackendWithCapabilities *mBackend; |
1415 | + CCSBackend *mGSettingsBackend; |
1416 | + std::string pluginToMatch; |
1417 | + CCSGSettingsBackendInterface overloadedInterface; |
1418 | + |
1419 | + static const std::string profileName; |
1420 | +}; |
1421 | + |
1422 | +const std::string CCSGSettingsBackendEnv::profileName = "mock"; |
1423 | + |
1424 | +INSTANTIATE_TEST_CASE_P (CCSGSettingsBackendConcept, CCSBackendConformanceTestReadWrite, |
1425 | + compizconfig::test::GenerateTestingParametersForBackendInterface <CCSGSettingsBackendEnv> ()); |
1426 | + |
1427 | |
1428 | === modified file 'compizconfig/gsettings/tests/test_gsettings_tests.cpp' |
1429 | --- compizconfig/gsettings/tests/test_gsettings_tests.cpp 2012-07-21 20:44:19 +0000 |
1430 | +++ compizconfig/gsettings/tests/test_gsettings_tests.cpp 2012-07-21 20:44:20 +0000 |
1431 | @@ -909,7 +909,7 @@ |
1432 | { |
1433 | GVariant *v = g_variant_new ("i", 1); |
1434 | |
1435 | - EXPECT_FALSE (checkReadVariantIsValid (v, TypeInt, "foo/bar")); |
1436 | + EXPECT_TRUE (checkReadVariantIsValid (v, TypeInt, "foo/bar")); |
1437 | |
1438 | g_variant_unref (v); |
1439 | } |
1440 | |
1441 | === modified file 'compizconfig/libcompizconfig/backend/src/ini.c' |
1442 | --- compizconfig/libcompizconfig/backend/src/ini.c 2012-07-21 20:44:19 +0000 |
1443 | +++ compizconfig/libcompizconfig/backend/src/ini.c 2012-07-21 20:44:20 +0000 |
1444 | @@ -605,6 +605,16 @@ |
1445 | free (fileName); |
1446 | } |
1447 | |
1448 | +static void |
1449 | +updateSetting (CCSBackend *backend, CCSContext *context, CCSPlugin *plugin, CCSSetting *setting) |
1450 | +{ |
1451 | + if (readInit (backend, context)) |
1452 | + { |
1453 | + readSetting (backend, context, setting); |
1454 | + readDone (backend, context); |
1455 | + } |
1456 | +} |
1457 | + |
1458 | static Bool |
1459 | getSettingIsReadOnly (CCSBackend *backend, CCSSetting * setting) |
1460 | { |
1461 | @@ -762,6 +772,7 @@ |
1462 | writeInit, |
1463 | writeSetting, |
1464 | writeDone, |
1465 | + updateSetting, |
1466 | NULL, |
1467 | getSettingIsReadOnly, |
1468 | getExistingProfiles, |
1469 | |
1470 | === modified file 'compizconfig/libcompizconfig/include/ccs-backend.h' |
1471 | --- compizconfig/libcompizconfig/include/ccs-backend.h 2012-07-21 20:44:19 +0000 |
1472 | +++ compizconfig/libcompizconfig/include/ccs-backend.h 2012-07-21 20:44:20 +0000 |
1473 | @@ -33,6 +33,7 @@ |
1474 | typedef struct _CCSBackendInterface CCSBackendInterface; |
1475 | |
1476 | typedef struct _CCSContext CCSContext; |
1477 | +typedef struct _CCSPlugin CCSPlugin; |
1478 | typedef struct _CCSSetting CCSSetting; |
1479 | |
1480 | struct _CCSBackend |
1481 | @@ -57,6 +58,8 @@ |
1482 | (CCSBackend *, CCSContext * context, CCSSetting * setting); |
1483 | typedef void (*CCSBackendWriteDoneFunc) (CCSBackend *, CCSContext * context); |
1484 | |
1485 | +typedef void (*CCSBackendUpdateFunc) (CCSBackend *, CCSContext *, CCSPlugin *, CCSSetting *); |
1486 | + |
1487 | typedef Bool (*CCSBackendGetSettingIsIntegratedFunc) (CCSBackend *, CCSSetting * setting); |
1488 | typedef Bool (*CCSBackendGetSettingIsReadOnlyFunc) (CCSBackend *, CCSSetting * setting); |
1489 | |
1490 | @@ -93,6 +96,7 @@ |
1491 | CCSBackendWriteSettingFunc writeSetting; |
1492 | CCSBackendWriteDoneFunc writeDone; |
1493 | |
1494 | + CCSBackendUpdateFunc updateSetting; |
1495 | |
1496 | CCSBackendGetSettingIsIntegratedFunc getSettingIsIntegrated; |
1497 | CCSBackendGetSettingIsReadOnlyFunc getSettingIsReadOnly; |
1498 | @@ -118,6 +122,7 @@ |
1499 | Bool ccsBackendWriteInit (CCSBackend *backend, CCSContext *context); |
1500 | void ccsBackendWriteSetting (CCSBackend *backend, CCSContext *context, CCSSetting *setting); |
1501 | void ccsBackendWriteDone (CCSBackend *backend, CCSContext *context); |
1502 | +void ccsBackendUpdateSetting (CCSBackend *backend, CCSContext *context, CCSPlugin *plugin, CCSSetting *setting); |
1503 | Bool ccsBackendGetSettingIsIntegrated (CCSBackend *backend, CCSSetting *setting); |
1504 | Bool ccsBackendGetSettingIsReadOnly (CCSBackend *backend, CCSSetting *setting); |
1505 | CCSStringList ccsBackendGetExistingProfiles (CCSBackend *backend, CCSContext *context); |
1506 | @@ -157,12 +162,18 @@ |
1507 | |
1508 | /* Backend opener method */ |
1509 | void * |
1510 | -ccsBackendOpen (char *name, CCSBackendInterface **interface, Bool *fellback); |
1511 | +ccsOpenBackend (const char *name, CCSBackendInterface **interface, Bool *fellback); |
1512 | |
1513 | /* Constructor method */ |
1514 | CCSBackend * |
1515 | ccsBackendNewWithInterface (CCSContext *context, const CCSBackendInterface *interface, void *dlhand); |
1516 | |
1517 | +typedef struct _CCSInterfaceTable CCSInterfaceTable; |
1518 | + |
1519 | +/* Constructor method */ |
1520 | +CCSBackendWithCapabilities * |
1521 | +ccsBackendWithCapabilitiesWrapBackend (const CCSInterfaceTable *interfaces, CCSBackend *backend); |
1522 | + |
1523 | CCSBackendInterface* getBackendInfo (void); |
1524 | |
1525 | COMPIZCONFIG_END_DECLS |
1526 | |
1527 | === modified file 'compizconfig/libcompizconfig/include/ccs.h' |
1528 | --- compizconfig/libcompizconfig/include/ccs.h 2012-07-21 20:44:19 +0000 |
1529 | +++ compizconfig/libcompizconfig/include/ccs.h 2012-07-21 20:44:20 +0000 |
1530 | @@ -808,6 +808,10 @@ |
1531 | CCSSettingColorValue* ccsGetColorArrayFromValueList (CCSSettingValueList list, |
1532 | int *num); |
1533 | |
1534 | +/* Copies lists */ |
1535 | +CCSSettingValueList |
1536 | +ccsCopyList (CCSSettingValueList l1, CCSSetting * setting); |
1537 | + |
1538 | /* Converts an array of data items to a setting value list. Behaves similar |
1539 | to ccsGetListFromStringArray */ |
1540 | CCSSettingValueList ccsGetValueListFromStringArray (const char **array, |
1541 | |
1542 | === modified file 'compizconfig/libcompizconfig/src/main.c' |
1543 | --- compizconfig/libcompizconfig/src/main.c 2012-07-21 20:44:19 +0000 |
1544 | +++ compizconfig/libcompizconfig/src/main.c 2012-07-21 20:44:20 +0000 |
1545 | @@ -1014,7 +1014,7 @@ |
1546 | CCSREF_OBJ (BackendWithCapabilities, CCSBackendWithCapabilities) |
1547 | |
1548 | static void * |
1549 | -openBackend (char *backend) |
1550 | +openBackend (const char *backend) |
1551 | { |
1552 | char *home = getenv ("HOME"); |
1553 | char *override_backend = getenv ("LIBCOMPIZCONFIG_BACKEND_PATH"); |
1554 | @@ -1158,7 +1158,7 @@ |
1555 | } |
1556 | |
1557 | void * |
1558 | -ccsOpenBackend (char *name, CCSBackendInterface **vt, Bool *fellback) |
1559 | +ccsOpenBackend (const char *name, CCSBackendInterface **vt, Bool *fellback) |
1560 | { |
1561 | void *dlhand = openBackend (name); |
1562 | if (!dlhand) |
1563 | @@ -1378,11 +1378,21 @@ |
1564 | return (GET_INTERFACE (CCSBackendInterface, backend))->writeDone != NULL; |
1565 | } |
1566 | |
1567 | +static Bool ccsBackendHasUpdateSetting (CCSBackend *backend) |
1568 | +{ |
1569 | + return (GET_INTERFACE (CCSBackendInterface, backend))->updateSetting != NULL; |
1570 | +} |
1571 | + |
1572 | void ccsBackendWriteDone (CCSBackend *backend, CCSContext *context) |
1573 | { |
1574 | return (*(GET_INTERFACE (CCSBackendInterface, backend))->writeDone) (backend, context); |
1575 | } |
1576 | |
1577 | +void ccsBackendUpdateSetting (CCSBackend *backend, CCSContext *context, CCSPlugin *plugin, CCSSetting *setting) |
1578 | +{ |
1579 | + return (*(GET_INTERFACE (CCSBackendInterface, backend))->updateSetting) (backend, context, plugin, setting); |
1580 | +} |
1581 | + |
1582 | static Bool ccsBackendHasGetSettingIsIntegrated (CCSBackend *backend) |
1583 | { |
1584 | return (GET_INTERFACE (CCSBackendInterface, backend))->getSettingIsIntegrated != NULL; |
1585 | @@ -1556,6 +1566,14 @@ |
1586 | ccsBackendWriteDone (bcPrivate->backend, context); |
1587 | } |
1588 | |
1589 | +static void ccsBackendCapabilitiesUpdateSettingWrapper (CCSBackend *backend, CCSContext *context, CCSPlugin *plugin, CCSSetting *setting) |
1590 | +{ |
1591 | + CAPABILITIES_PRIV (backend); |
1592 | + |
1593 | + if (ccsBackendHasUpdateSetting (bcPrivate->backend)) |
1594 | + ccsBackendUpdateSetting (bcPrivate->backend, context, plugin, setting); |
1595 | +} |
1596 | + |
1597 | static Bool ccsBackendCapabilitiesGetSettingIsIntegratedWrapper (CCSBackend *backend, CCSSetting *setting) |
1598 | { |
1599 | CAPABILITIES_PRIV (backend); |
1600 | @@ -1614,8 +1632,14 @@ |
1601 | return FALSE; |
1602 | break; |
1603 | case TypeBool: |
1604 | - if (l1->data->value.asBool != l2->data->value.asBool) |
1605 | - return FALSE; |
1606 | + { |
1607 | + Bool bothTrue = (l1->data->value.asBool && l2->data->value.asBool); |
1608 | + Bool bothFalse = (!l1->data->value.asBool && !l2->data->value.asBool); |
1609 | + |
1610 | + /* Use the boolean operators as TRUE/FALSE can be redefined */ |
1611 | + if (!bothTrue && !bothFalse) |
1612 | + return FALSE; |
1613 | + } |
1614 | break; |
1615 | case TypeFloat: |
1616 | if (l1->data->value.asFloat != l2->data->value.asFloat) |
1617 | @@ -2300,13 +2324,11 @@ |
1618 | return TRUE; |
1619 | } |
1620 | |
1621 | -static CCSSettingValueList |
1622 | +CCSSettingValueList |
1623 | ccsCopyList (CCSSettingValueList l1, CCSSetting * setting) |
1624 | { |
1625 | CCSSettingValueList l2 = NULL; |
1626 | |
1627 | - SETTING_PRIV (setting) |
1628 | - |
1629 | while (l1) |
1630 | { |
1631 | CCSSettingValue *value = calloc (1, sizeof (CCSSettingValue)); |
1632 | @@ -2317,7 +2339,7 @@ |
1633 | value->parent = setting; |
1634 | value->isListChild = TRUE; |
1635 | |
1636 | - switch (sPrivate->info.forList.listType) |
1637 | + switch (ccsSettingGetInfo (setting)->forList.listType) |
1638 | { |
1639 | case TypeInt: |
1640 | value->value.asInt = l1->data->value.asInt; |
1641 | @@ -5520,6 +5542,7 @@ |
1642 | ccsBackendCapabilitiesWriteInitWrapper, |
1643 | ccsBackendCapabilitiesWriteSettingWrapper, |
1644 | ccsBackendCapabilitiesWriteDoneWrapper, |
1645 | + ccsBackendCapabilitiesUpdateSettingWrapper, |
1646 | ccsBackendCapabilitiesGetSettingIsIntegratedWrapper, |
1647 | ccsBackendCapabilitiesGetSettingIsReadOnlyWrapper, |
1648 | ccsBackendCapabilitiesGetExistingProfilesWrapper, |
1649 | |
1650 | === modified file 'compizconfig/libcompizconfig/tests/compizconfig_test_ccs_mock_backend_conformance.cpp' |
1651 | --- compizconfig/libcompizconfig/tests/compizconfig_test_ccs_mock_backend_conformance.cpp 2012-07-21 20:44:19 +0000 |
1652 | +++ compizconfig/libcompizconfig/tests/compizconfig_test_ccs_mock_backend_conformance.cpp 2012-07-21 20:44:20 +0000 |
1653 | @@ -15,6 +15,7 @@ |
1654 | using ::testing::Combine; |
1655 | using ::testing::ValuesIn; |
1656 | using ::testing::Values; |
1657 | +using ::testing::AtLeast; |
1658 | |
1659 | namespace |
1660 | { |
1661 | @@ -49,6 +50,7 @@ |
1662 | |
1663 | CCSBackend * SetUp (CCSContext *context, CCSContextGMock *gmockContext) |
1664 | { |
1665 | + mContext = context; |
1666 | mBackend = ccsMockBackendNew (); |
1667 | mBackendGMock = (CCSBackendGMock *) ccsObjectGetPrivate (mBackend); |
1668 | |
1669 | @@ -59,6 +61,13 @@ |
1670 | this, |
1671 | &MockCCSBackendConceptTestEnvironment::ReadValueIntoSetting))); |
1672 | |
1673 | + ON_CALL (*mBackendGMock, updateSetting (_, _, _)) |
1674 | + .WillByDefault ( |
1675 | + WithArgs<2> ( |
1676 | + Invoke ( |
1677 | + this, |
1678 | + &MockCCSBackendConceptTestEnvironment::ReadValueIntoSetting))); |
1679 | + |
1680 | ON_CALL (*mBackendGMock, writeSetting (_, _)) |
1681 | .WillByDefault ( |
1682 | WithArgs<1> ( |
1683 | @@ -72,7 +81,6 @@ |
1684 | void TearDown (CCSBackend *backend) |
1685 | { |
1686 | ccsFreeMockBackend (backend); |
1687 | - |
1688 | } |
1689 | |
1690 | void PreWrite (CCSContextGMock *gmockContext, |
1691 | @@ -83,8 +91,17 @@ |
1692 | EXPECT_CALL (*mBackendGMock, writeSetting (_, _)); |
1693 | EXPECT_CALL (*gmockPlugin, getName ()); |
1694 | EXPECT_CALL (*gmockSetting, getName ()); |
1695 | - EXPECT_CALL (*gmockSetting, getType ()); |
1696 | EXPECT_CALL (*gmockSetting, getParent ()); |
1697 | + |
1698 | + if (type == TypeList) |
1699 | + { |
1700 | + EXPECT_CALL (*gmockSetting, getType ()).Times (AtLeast (1)); |
1701 | + EXPECT_CALL (*gmockSetting, getDefaultValue ()).Times (AtLeast (1)); |
1702 | + } |
1703 | + else |
1704 | + { |
1705 | + EXPECT_CALL (*gmockSetting, getType ()); |
1706 | + } |
1707 | } |
1708 | |
1709 | void PostWrite (CCSContextGMock *gmockContext, |
1710 | @@ -180,8 +197,17 @@ |
1711 | EXPECT_CALL (*mBackendGMock, readSetting (_, _)); |
1712 | EXPECT_CALL (*gmockPlugin, getName ()); |
1713 | EXPECT_CALL (*gmockSetting, getName ()); |
1714 | - EXPECT_CALL (*gmockSetting, getType ()); |
1715 | EXPECT_CALL (*gmockSetting, getParent ()); |
1716 | + |
1717 | + if (type == TypeList) |
1718 | + { |
1719 | + EXPECT_CALL (*gmockSetting, getType ()).Times (AtLeast (1)); |
1720 | + EXPECT_CALL (*gmockSetting, getInfo ()).Times (AtLeast (1)); |
1721 | + } |
1722 | + else |
1723 | + { |
1724 | + EXPECT_CALL (*gmockSetting, getType ()); |
1725 | + } |
1726 | } |
1727 | |
1728 | void PostRead (CCSContextGMock *gmockContext, |
1729 | @@ -252,11 +278,57 @@ |
1730 | } |
1731 | |
1732 | virtual CCSSettingValueList ReadListAtKey (const std::string &plugin, |
1733 | - const std::string &key) |
1734 | + const std::string &key, |
1735 | + CCSSettingInfo *info) |
1736 | { |
1737 | return *(ValueForKeyRetreival <boost::shared_ptr <CCSListWrapper> > ().GetValueForKey (keynameFromPluginKey (plugin, key), mValues)); |
1738 | } |
1739 | |
1740 | + void PreUpdate (CCSContextGMock *gmockContext, |
1741 | + CCSPluginGMock *gmockPlugin, |
1742 | + CCSSettingGMock *gmockSetting, |
1743 | + CCSSettingType type) |
1744 | + { |
1745 | + EXPECT_CALL (*mBackendGMock, updateSetting (_, _, _)); |
1746 | + EXPECT_CALL (*gmockPlugin, getName ()); |
1747 | + EXPECT_CALL (*gmockSetting, getName ()); |
1748 | + EXPECT_CALL (*gmockSetting, getParent ()); |
1749 | + |
1750 | + if (type == TypeList) |
1751 | + { |
1752 | + EXPECT_CALL (*gmockSetting, getType ()).Times (AtLeast (1)); |
1753 | + EXPECT_CALL (*gmockSetting, getInfo ()).Times (AtLeast (1)); |
1754 | + } |
1755 | + else |
1756 | + { |
1757 | + EXPECT_CALL (*gmockSetting, getType ()); |
1758 | + } |
1759 | + } |
1760 | + |
1761 | + void PostUpdate (CCSContextGMock *gmockContext, |
1762 | + CCSPluginGMock *gmockPlugin, |
1763 | + CCSSettingGMock *gmockSetting, |
1764 | + CCSSettingType type) |
1765 | + { |
1766 | + } |
1767 | + |
1768 | + bool UpdateSettingAtKey (const std::string &plugin, |
1769 | + const std::string &setting) |
1770 | + { |
1771 | + CCSPlugin *cplugin = ccsFindPlugin (mContext, plugin.c_str ()); |
1772 | + |
1773 | + if (!cplugin) |
1774 | + return false; |
1775 | + |
1776 | + CCSSetting *csetting = ccsFindSetting (cplugin, setting.c_str ()); |
1777 | + |
1778 | + if (!csetting) |
1779 | + return false; |
1780 | + |
1781 | + ccsBackendUpdateSetting (mBackend, mContext, cplugin, csetting); |
1782 | + return true; |
1783 | + } |
1784 | + |
1785 | protected: |
1786 | |
1787 | void ReadValueIntoSetting (CCSSetting *setting) |
1788 | @@ -317,9 +389,12 @@ |
1789 | break; |
1790 | |
1791 | case TypeList: |
1792 | + { |
1793 | + CCSSettingInfo *info = ccsSettingGetInfo (setting); |
1794 | |
1795 | - ccsSetList (setting, ReadListAtKey (plugin, key), FALSE); |
1796 | - break; |
1797 | + ccsSetList (setting, ReadListAtKey (plugin, key, info), FALSE); |
1798 | + } |
1799 | + break; |
1800 | |
1801 | default: |
1802 | |
1803 | @@ -405,11 +480,18 @@ |
1804 | break; |
1805 | |
1806 | case TypeList: |
1807 | + { |
1808 | + CCSSettingValueList listCopy = NULL; |
1809 | |
1810 | ccsGetList (setting, &vList); |
1811 | - WriteListAtKey (plugin, key, VariantTypes (boost::make_shared <CCSListWrapper> (vList, false, ccsSettingGetInfo (setting)->forList.listType))); |
1812 | + listCopy = ccsCopyList (vList, setting); |
1813 | + |
1814 | + WriteListAtKey (plugin, key, VariantTypes (boost::make_shared <CCSListWrapper> (listCopy, true, |
1815 | + ccsSettingGetInfo (setting)->forList.listType, |
1816 | + boost::shared_ptr <CCSSettingInfo> (), |
1817 | + boost::shared_ptr <CCSSetting> ()))); |
1818 | break; |
1819 | - |
1820 | + } |
1821 | default: |
1822 | |
1823 | throw std::exception (); |
1824 | @@ -420,6 +502,7 @@ |
1825 | |
1826 | CCSBackend *mBackend; |
1827 | CCSBackendGMock *mBackendGMock; |
1828 | + CCSContext *mContext; |
1829 | std::map <std::string, VariantTypes> mValues; |
1830 | }; |
1831 | |
1832 | |
1833 | === modified file 'compizconfig/mocks/libcompizconfig/compizconfig_ccs_backend_mock.cpp' |
1834 | --- compizconfig/mocks/libcompizconfig/compizconfig_ccs_backend_mock.cpp 2012-07-21 20:44:19 +0000 |
1835 | +++ compizconfig/mocks/libcompizconfig/compizconfig_ccs_backend_mock.cpp 2012-07-21 20:44:20 +0000 |
1836 | @@ -21,6 +21,7 @@ |
1837 | CCSBackendGMock::ccsBackendWriteInit, |
1838 | CCSBackendGMock::ccsBackendWriteSetting, |
1839 | CCSBackendGMock::ccsBackendWriteDone, |
1840 | + CCSBackendGMock::ccsBackendUpdateSetting, |
1841 | CCSBackendGMock::ccsBackendGetSettingIsIntegrated, |
1842 | CCSBackendGMock::ccsBackendGetSettingIsReadOnly, |
1843 | CCSBackendGMock::ccsBackendGetExistingProfiles, |
1844 | |
1845 | === modified file 'compizconfig/mocks/libcompizconfig/compizconfig_ccs_backend_mock.h' |
1846 | --- compizconfig/mocks/libcompizconfig/compizconfig_ccs_backend_mock.h 2012-07-21 20:44:19 +0000 |
1847 | +++ compizconfig/mocks/libcompizconfig/compizconfig_ccs_backend_mock.h 2012-07-21 20:44:20 +0000 |
1848 | @@ -29,6 +29,7 @@ |
1849 | virtual Bool writeInit (CCSContext *conxtext) = 0; |
1850 | virtual void writeSetting (CCSContext *context, CCSSetting *setting) = 0; |
1851 | virtual void writeDone (CCSContext *context) = 0; |
1852 | + virtual void updateSetting (CCSContext *context, CCSPlugin *plugin, CCSSetting *setting) = 0; |
1853 | virtual Bool getSettingIsIntegrated (CCSSetting *setting) = 0; |
1854 | virtual Bool getSettingIsReadOnly (CCSSetting *setting) = 0; |
1855 | virtual CCSStringList getExistingProfiles (CCSContext *context) = 0; |
1856 | @@ -62,6 +63,7 @@ |
1857 | MOCK_METHOD1 (writeInit, Bool (CCSContext *)); |
1858 | MOCK_METHOD2 (writeSetting, void (CCSContext *, CCSSetting *)); |
1859 | MOCK_METHOD1 (writeDone, void (CCSContext *)); |
1860 | + MOCK_METHOD3 (updateSetting, void (CCSContext *, CCSPlugin *, CCSSetting *)); |
1861 | MOCK_METHOD1 (getSettingIsIntegrated, Bool (CCSSetting *)); |
1862 | MOCK_METHOD1 (getSettingIsReadOnly, Bool (CCSSetting *)); |
1863 | MOCK_METHOD1 (getExistingProfiles, CCSStringList (CCSContext *)); |
1864 | @@ -144,6 +146,11 @@ |
1865 | ((CCSBackendGMock *) ccsObjectGetPrivate (backend))->writeDone (context); |
1866 | } |
1867 | |
1868 | + static void ccsBackendUpdateSetting (CCSBackend *backend, CCSContext *context, CCSPlugin *plugin, CCSSetting *setting) |
1869 | + { |
1870 | + ((CCSBackendGMock *) ccsObjectGetPrivate (backend))->updateSetting (context, plugin, setting); |
1871 | + } |
1872 | + |
1873 | static Bool ccsBackendGetSettingIsIntegrated (CCSBackend *backend, CCSSetting *setting) |
1874 | { |
1875 | return ((CCSBackendGMock *) ccsObjectGetPrivate (backend))->getSettingIsIntegrated (setting); |
1876 | |
1877 | === modified file 'compizconfig/tests/compizconfig_backend_concept_test.h' |
1878 | --- compizconfig/tests/compizconfig_backend_concept_test.h 2012-07-21 20:44:19 +0000 |
1879 | +++ compizconfig/tests/compizconfig_backend_concept_test.h 2012-07-21 20:44:20 +0000 |
1880 | @@ -13,6 +13,8 @@ |
1881 | #include <gtest/gtest.h> |
1882 | #include <gmock/gmock.h> |
1883 | |
1884 | +#include <X11/keysym.h> |
1885 | + |
1886 | #include <ccs-backend.h> |
1887 | #include <ccs.h> |
1888 | |
1889 | @@ -24,10 +26,15 @@ |
1890 | using ::testing::SetArgPointee; |
1891 | using ::testing::DoAll; |
1892 | using ::testing::Return; |
1893 | +using ::testing::ReturnNull; |
1894 | using ::testing::MakeMatcher; |
1895 | using ::testing::Matcher; |
1896 | using ::testing::MatcherInterface; |
1897 | using ::testing::MatchResultListener; |
1898 | +using ::testing::AtLeast; |
1899 | + |
1900 | +MATCHER(IsTrue, "Is True") { if (arg) return true; else return false; } |
1901 | +MATCHER(IsFalse, "Is False") { if (!arg) return true; else return false; } |
1902 | |
1903 | class ListEqualityMatcher : |
1904 | public MatcherInterface <CCSSettingValueList> |
1905 | @@ -77,6 +84,13 @@ |
1906 | return false; |
1907 | } |
1908 | |
1909 | +::std::ostream & |
1910 | +operator<< (::std::ostream &os, const CCSSettingColorValue &v) |
1911 | +{ |
1912 | + return os << "Red: " << std::hex << v.color.red << "Blue: " << std::hex << v.color.blue << "Green: " << v.color.green << "Alpha: " << v.color.alpha |
1913 | + << std::dec << std::endl; |
1914 | +} |
1915 | + |
1916 | bool |
1917 | operator== (const CCSSettingKeyValue &lhs, |
1918 | const CCSSettingKeyValue &rhs) |
1919 | @@ -86,6 +100,12 @@ |
1920 | return false; |
1921 | } |
1922 | |
1923 | +::std::ostream & |
1924 | +operator<< (::std::ostream &os, const CCSSettingKeyValue &v) |
1925 | +{ |
1926 | + return os << "Keysym: " << v.keysym << " KeyModMask " << std::hex << v.keyModMask << std::dec << std::endl; |
1927 | +} |
1928 | + |
1929 | bool |
1930 | operator== (const CCSSettingButtonValue &lhs, |
1931 | const CCSSettingButtonValue &rhs) |
1932 | @@ -95,6 +115,42 @@ |
1933 | return false; |
1934 | } |
1935 | |
1936 | +::std::ostream & |
1937 | +operator<< (::std::ostream &os, const CCSSettingButtonValue &v) |
1938 | +{ |
1939 | + return os << "Button " << v.button << "Button Key Mask: " << std::hex << v.buttonModMask << "Edge Mask: " << v.edgeMask << std::dec << std::endl; |
1940 | +} |
1941 | + |
1942 | +class CharacterWrapper : |
1943 | + boost::noncopyable |
1944 | +{ |
1945 | + public: |
1946 | + |
1947 | + explicit CharacterWrapper (char *c) : |
1948 | + mChar (c) |
1949 | + { |
1950 | + } |
1951 | + |
1952 | + ~CharacterWrapper () |
1953 | + { |
1954 | + free (mChar); |
1955 | + } |
1956 | + |
1957 | + operator char * () |
1958 | + { |
1959 | + return mChar; |
1960 | + } |
1961 | + |
1962 | + operator const char * () const |
1963 | + { |
1964 | + return mChar; |
1965 | + } |
1966 | + |
1967 | + private: |
1968 | + |
1969 | + char *mChar; |
1970 | +}; |
1971 | + |
1972 | class CCSListWrapper : |
1973 | boost::noncopyable |
1974 | { |
1975 | @@ -102,10 +158,16 @@ |
1976 | |
1977 | typedef boost::shared_ptr <CCSListWrapper> Ptr; |
1978 | |
1979 | - CCSListWrapper (CCSSettingValueList list, bool freeItems, CCSSettingType type) : |
1980 | + CCSListWrapper (CCSSettingValueList list, |
1981 | + bool freeItems, |
1982 | + CCSSettingType type, |
1983 | + const boost::shared_ptr <CCSSettingInfo> &listInfo, |
1984 | + const boost::shared_ptr <CCSSetting> &settingReference) : |
1985 | mList (list), |
1986 | mFreeItems (freeItems), |
1987 | - mType (type) |
1988 | + mType (type), |
1989 | + mListInfo (listInfo), |
1990 | + mSettingReference (settingReference) |
1991 | { |
1992 | } |
1993 | |
1994 | @@ -130,6 +192,8 @@ |
1995 | CCSSettingValueList mList; |
1996 | bool mFreeItems; |
1997 | CCSSettingType mType; |
1998 | + boost::shared_ptr <CCSSettingInfo> mListInfo; |
1999 | + boost::shared_ptr <CCSSetting> mSettingReference; |
2000 | }; |
2001 | |
2002 | typedef boost::variant <bool, |
2003 | @@ -146,6 +210,8 @@ |
2004 | { |
2005 | public: |
2006 | |
2007 | + typedef boost::shared_ptr <CCSBackendConceptTestEnvironmentInterface> Ptr; |
2008 | + |
2009 | virtual ~CCSBackendConceptTestEnvironmentInterface () {}; |
2010 | virtual CCSBackend * SetUp (CCSContext *context, |
2011 | CCSContextGMock *gmockContext) = 0; |
2012 | @@ -224,7 +290,42 @@ |
2013 | virtual Bool ReadBellAtKey (const std::string &plugin, |
2014 | const std::string &key) = 0; |
2015 | virtual CCSSettingValueList ReadListAtKey (const std::string &plugin, |
2016 | - const std::string &key) = 0; |
2017 | + const std::string &key, |
2018 | + CCSSettingInfo *info) = 0; |
2019 | + |
2020 | + virtual void PreUpdate (CCSContextGMock *, |
2021 | + CCSPluginGMock *, |
2022 | + CCSSettingGMock *, |
2023 | + CCSSettingType) = 0; |
2024 | + virtual void PostUpdate (CCSContextGMock *, |
2025 | + CCSPluginGMock *, |
2026 | + CCSSettingGMock *, |
2027 | + CCSSettingType) = 0; |
2028 | + |
2029 | + virtual bool UpdateSettingAtKey (const std::string &plugin, |
2030 | + const std::string &setting) = 0; |
2031 | +}; |
2032 | + |
2033 | +class CCSBackendConceptTestEnvironmentFactoryInterface |
2034 | +{ |
2035 | + public: |
2036 | + |
2037 | + virtual ~CCSBackendConceptTestEnvironmentFactoryInterface () {} |
2038 | + |
2039 | + virtual CCSBackendConceptTestEnvironmentInterface::Ptr ConstructTestEnv () = 0; |
2040 | +}; |
2041 | + |
2042 | +template <typename I> |
2043 | +class CCSBackendConceptTestEnvironmentFactory : |
2044 | + public CCSBackendConceptTestEnvironmentFactoryInterface |
2045 | +{ |
2046 | + public: |
2047 | + |
2048 | + CCSBackendConceptTestEnvironmentInterface::Ptr |
2049 | + ConstructTestEnv () |
2050 | + { |
2051 | + return boost::shared_static_cast <I> (boost::make_shared <I> ()); |
2052 | + } |
2053 | }; |
2054 | |
2055 | namespace |
2056 | @@ -241,7 +342,7 @@ |
2057 | const VariantTypes &value, |
2058 | CCSSetting *setting, |
2059 | const WriteFunc &write, |
2060 | - CCSBackendConceptTestEnvironmentInterface *env) |
2061 | + const CCSBackendConceptTestEnvironmentInterface::Ptr &env) |
2062 | { |
2063 | CCSSettingGMock *gmock (getSettingGMockFromSetting (setting)); |
2064 | EXPECT_CALL (*gmock, getInt (_)).WillRepeatedly (DoAll ( |
2065 | @@ -257,7 +358,7 @@ |
2066 | const VariantTypes &value, |
2067 | CCSSetting *setting, |
2068 | const WriteFunc &write, |
2069 | - CCSBackendConceptTestEnvironmentInterface *env) |
2070 | + const CCSBackendConceptTestEnvironmentInterface::Ptr &env) |
2071 | { |
2072 | CCSSettingGMock *gmock (getSettingGMockFromSetting (setting)); |
2073 | EXPECT_CALL (*gmock, getBool (_)).WillRepeatedly (DoAll ( |
2074 | @@ -265,7 +366,13 @@ |
2075 | boolToBool (boost::get <bool> (value))), |
2076 | Return (TRUE))); |
2077 | write (); |
2078 | - EXPECT_EQ (env->ReadBoolAtKey (plugin, key), boolToBool (boost::get <bool> (value))); |
2079 | + |
2080 | + bool v (boost::get <bool> (value)); |
2081 | + |
2082 | + if (v) |
2083 | + EXPECT_THAT (env->ReadBoolAtKey (plugin, key), IsTrue ()); |
2084 | + else |
2085 | + EXPECT_THAT (env->ReadBoolAtKey (plugin, key), IsFalse ()); |
2086 | } |
2087 | |
2088 | void SetFloatWriteExpectation (const std::string &plugin, |
2089 | @@ -273,7 +380,7 @@ |
2090 | const VariantTypes &value, |
2091 | CCSSetting *setting, |
2092 | const WriteFunc &write, |
2093 | - CCSBackendConceptTestEnvironmentInterface *env) |
2094 | + const CCSBackendConceptTestEnvironmentInterface::Ptr &env) |
2095 | { |
2096 | CCSSettingGMock *gmock (getSettingGMockFromSetting (setting)); |
2097 | EXPECT_CALL (*gmock, getFloat (_)).WillRepeatedly (DoAll ( |
2098 | @@ -289,7 +396,7 @@ |
2099 | const VariantTypes &value, |
2100 | CCSSetting *setting, |
2101 | const WriteFunc &write, |
2102 | - CCSBackendConceptTestEnvironmentInterface *env) |
2103 | + const CCSBackendConceptTestEnvironmentInterface::Ptr &env) |
2104 | { |
2105 | CCSSettingGMock *gmock (getSettingGMockFromSetting (setting)); |
2106 | EXPECT_CALL (*gmock, getString (_)).WillRepeatedly (DoAll ( |
2107 | @@ -297,7 +404,7 @@ |
2108 | const_cast <char *> (boost::get <const char *> (value))), |
2109 | Return (TRUE))); |
2110 | write (); |
2111 | - EXPECT_EQ (env->ReadStringAtKey (plugin, key), boost::get <const char *> (value)); |
2112 | + EXPECT_EQ (std::string (env->ReadStringAtKey (plugin, key)), std::string (boost::get <const char *> (value))); |
2113 | } |
2114 | |
2115 | void SetColorWriteExpectation (const std::string &plugin, |
2116 | @@ -305,7 +412,7 @@ |
2117 | const VariantTypes &value, |
2118 | CCSSetting *setting, |
2119 | const WriteFunc &write, |
2120 | - CCSBackendConceptTestEnvironmentInterface *env) |
2121 | + const CCSBackendConceptTestEnvironmentInterface::Ptr &env) |
2122 | { |
2123 | CCSSettingGMock *gmock (getSettingGMockFromSetting (setting)); |
2124 | EXPECT_CALL (*gmock, getColor (_)).WillRepeatedly (DoAll ( |
2125 | @@ -313,6 +420,7 @@ |
2126 | boost::get <CCSSettingColorValue> (value)), |
2127 | Return (TRUE))); |
2128 | write (); |
2129 | + |
2130 | EXPECT_EQ (env->ReadColorAtKey (plugin, key), boost::get <CCSSettingColorValue> (value)); |
2131 | } |
2132 | |
2133 | @@ -321,7 +429,7 @@ |
2134 | const VariantTypes &value, |
2135 | CCSSetting *setting, |
2136 | const WriteFunc &write, |
2137 | - CCSBackendConceptTestEnvironmentInterface *env) |
2138 | + const CCSBackendConceptTestEnvironmentInterface::Ptr &env) |
2139 | { |
2140 | CCSSettingGMock *gmock (getSettingGMockFromSetting (setting)); |
2141 | EXPECT_CALL (*gmock, getKey (_)).WillRepeatedly (DoAll ( |
2142 | @@ -337,7 +445,7 @@ |
2143 | const VariantTypes &value, |
2144 | CCSSetting *setting, |
2145 | const WriteFunc &write, |
2146 | - CCSBackendConceptTestEnvironmentInterface *env) |
2147 | + const CCSBackendConceptTestEnvironmentInterface::Ptr &env) |
2148 | { |
2149 | CCSSettingGMock *gmock (getSettingGMockFromSetting (setting)); |
2150 | EXPECT_CALL (*gmock, getButton (_)).WillRepeatedly (DoAll ( |
2151 | @@ -353,7 +461,7 @@ |
2152 | const VariantTypes &value, |
2153 | CCSSetting *setting, |
2154 | const WriteFunc &write, |
2155 | - CCSBackendConceptTestEnvironmentInterface *env) |
2156 | + const CCSBackendConceptTestEnvironmentInterface::Ptr &env) |
2157 | { |
2158 | CCSSettingGMock *gmock (getSettingGMockFromSetting (setting)); |
2159 | EXPECT_CALL (*gmock, getEdge (_)).WillRepeatedly (DoAll ( |
2160 | @@ -369,7 +477,7 @@ |
2161 | const VariantTypes &value, |
2162 | CCSSetting *setting, |
2163 | const WriteFunc &write, |
2164 | - CCSBackendConceptTestEnvironmentInterface *env) |
2165 | + const CCSBackendConceptTestEnvironmentInterface::Ptr &env) |
2166 | { |
2167 | CCSSettingGMock *gmock (getSettingGMockFromSetting (setting)); |
2168 | EXPECT_CALL (*gmock, getBell (_)).WillRepeatedly (DoAll ( |
2169 | @@ -377,7 +485,12 @@ |
2170 | boolToBool (boost::get <bool> (value))), |
2171 | Return (TRUE))); |
2172 | write (); |
2173 | - EXPECT_EQ (env->ReadBellAtKey (plugin, key), boolToBool (boost::get <bool> (value))); |
2174 | + bool v (boost::get <bool> (value)); |
2175 | + |
2176 | + if (v) |
2177 | + EXPECT_THAT (env->ReadBellAtKey (plugin, key), IsTrue ()); |
2178 | + else |
2179 | + EXPECT_THAT (env->ReadBellAtKey (plugin, key), IsFalse ()); |
2180 | } |
2181 | |
2182 | void SetMatchWriteExpectation (const std::string &plugin, |
2183 | @@ -385,7 +498,7 @@ |
2184 | const VariantTypes &value, |
2185 | CCSSetting *setting, |
2186 | const WriteFunc &write, |
2187 | - CCSBackendConceptTestEnvironmentInterface *env) |
2188 | + const CCSBackendConceptTestEnvironmentInterface::Ptr &env) |
2189 | { |
2190 | CCSSettingGMock *gmock (getSettingGMockFromSetting (setting)); |
2191 | EXPECT_CALL (*gmock, getMatch (_)).WillRepeatedly (DoAll ( |
2192 | @@ -393,7 +506,7 @@ |
2193 | const_cast <char *> (boost::get <const char *> (value))), |
2194 | Return (TRUE))); |
2195 | write (); |
2196 | - EXPECT_EQ (env->ReadMatchAtKey (plugin, key), boost::get <const char *> (value)); |
2197 | + EXPECT_EQ (std::string (env->ReadMatchAtKey (plugin, key)), std::string (boost::get <const char *> (value))); |
2198 | } |
2199 | |
2200 | void SetListWriteExpectation (const std::string &plugin, |
2201 | @@ -401,21 +514,24 @@ |
2202 | const VariantTypes &value, |
2203 | CCSSetting *setting, |
2204 | const WriteFunc &write, |
2205 | - CCSBackendConceptTestEnvironmentInterface *env) |
2206 | + const CCSBackendConceptTestEnvironmentInterface::Ptr &env) |
2207 | { |
2208 | CCSSettingGMock *gmock (getSettingGMockFromSetting (setting)); |
2209 | CCSSettingValueList list = *(boost::get <boost::shared_ptr <CCSListWrapper> > (value)); |
2210 | - boost::shared_ptr <CCSSettingInfo> info (boost::make_shared <CCSSettingInfo> ()); |
2211 | + |
2212 | + EXPECT_CALL (*gmock, getInfo ()); |
2213 | + |
2214 | + CCSSettingInfo *info = ccsSettingGetInfo (setting); |
2215 | |
2216 | info->forList.listType = (boost::get <boost::shared_ptr <CCSListWrapper> > (value))->type (); |
2217 | |
2218 | - EXPECT_CALL (*gmock, getInfo ()).WillRepeatedly (Return (info.get ())); |
2219 | + EXPECT_CALL (*gmock, getInfo ()).Times (AtLeast (1)); |
2220 | EXPECT_CALL (*gmock, getList (_)).WillRepeatedly (DoAll ( |
2221 | SetArgPointee <0> ( |
2222 | list), |
2223 | Return (TRUE))); |
2224 | write (); |
2225 | - EXPECT_THAT (env->ReadListAtKey (plugin, key), ListEqual (ccsSettingGetInfo (setting)->forList, list)); |
2226 | + EXPECT_THAT (env->ReadListAtKey (plugin, key, info), ListEqual (ccsSettingGetInfo (setting)->forList, list)); |
2227 | } |
2228 | |
2229 | void SetIntReadExpectation (CCSSettingGMock *gmock, const VariantTypes &value) |
2230 | @@ -425,12 +541,22 @@ |
2231 | |
2232 | void SetBoolReadExpectation (CCSSettingGMock *gmock, const VariantTypes &value) |
2233 | { |
2234 | - EXPECT_CALL (*gmock, setBool (boolToBool (boost::get <bool> (value)), _)); |
2235 | + bool v (boost::get <bool> (value)); |
2236 | + |
2237 | + if (v) |
2238 | + EXPECT_CALL (*gmock, setBool (IsTrue (), _)); |
2239 | + else |
2240 | + EXPECT_CALL (*gmock, setBool (IsFalse (), _)); |
2241 | } |
2242 | |
2243 | void SetBellReadExpectation (CCSSettingGMock *gmock, const VariantTypes &value) |
2244 | { |
2245 | - EXPECT_CALL (*gmock, setBell (boolToBool (boost::get <bool> (value)), _)); |
2246 | + bool v (boost::get <bool> (value)); |
2247 | + |
2248 | + if (v) |
2249 | + EXPECT_CALL (*gmock, setBell (IsTrue (), _)); |
2250 | + else |
2251 | + EXPECT_CALL (*gmock, setBell (IsFalse (), _)); |
2252 | } |
2253 | |
2254 | void SetFloatReadExpectation (CCSSettingGMock *gmock, const VariantTypes &value) |
2255 | @@ -468,14 +594,15 @@ |
2256 | EXPECT_CALL (*gmock, setEdge (boost::get <unsigned int> (value), _)); |
2257 | } |
2258 | |
2259 | +CCSSettingInfo globalListInfo; |
2260 | + |
2261 | void SetListReadExpectation (CCSSettingGMock *gmock, const VariantTypes &value) |
2262 | { |
2263 | - CCSSettingInfo info; |
2264 | - |
2265 | - info.forList.listType = (boost::get <boost::shared_ptr <CCSListWrapper> > (value))->type (); |
2266 | - info.forList.listInfo = NULL; |
2267 | - |
2268 | - EXPECT_CALL (*gmock, setList (ListEqual (info.forList, *(boost::get <boost::shared_ptr <CCSListWrapper> > (value))), _)); |
2269 | + globalListInfo.forList.listType = (boost::get <boost::shared_ptr <CCSListWrapper> > (value))->type (); |
2270 | + globalListInfo.forList.listInfo = NULL; |
2271 | + |
2272 | + ON_CALL (*gmock, getInfo ()).WillByDefault (Return (&globalListInfo)); |
2273 | + EXPECT_CALL (*gmock, setList (ListEqual (globalListInfo.forList, *(boost::get <boost::shared_ptr <CCSListWrapper> > (value))), _)); |
2274 | } |
2275 | |
2276 | } |
2277 | @@ -486,9 +613,10 @@ |
2278 | |
2279 | typedef boost::shared_ptr <CCSBackendConceptTestParamInterface> Ptr; |
2280 | |
2281 | - typedef boost::function <void (const std::string &plugin, |
2282 | - const std::string &keyname, |
2283 | - const VariantTypes &value)> NativeWriteMethod; |
2284 | + typedef void (CCSBackendConceptTestEnvironmentInterface::*NativeWriteMethod) (const std::string &plugin, |
2285 | + const std::string &keyname, |
2286 | + const VariantTypes &value); |
2287 | + |
2288 | typedef boost::function <void (CCSSettingGMock *, |
2289 | const VariantTypes &)> SetReadExpectation; |
2290 | typedef boost::function <void (const std::string &, |
2291 | @@ -496,11 +624,16 @@ |
2292 | const VariantTypes &, |
2293 | CCSSetting *, |
2294 | const WriteFunc &, |
2295 | - CCSBackendConceptTestEnvironmentInterface *)> SetWriteExpectation; |
2296 | - |
2297 | - virtual CCSBackendConceptTestEnvironmentInterface * testEnv () = 0; |
2298 | + const CCSBackendConceptTestEnvironmentInterface::Ptr & )> SetWriteExpectation; |
2299 | + |
2300 | + virtual void TearDown (CCSBackend *) = 0; |
2301 | + |
2302 | + virtual CCSBackendConceptTestEnvironmentInterface::Ptr testEnv () = 0; |
2303 | virtual VariantTypes & value () = 0; |
2304 | - virtual NativeWriteMethod & nativeWrite () = 0; |
2305 | + virtual void nativeWrite (const CCSBackendConceptTestEnvironmentInterface::Ptr & iface, |
2306 | + const std::string &plugin, |
2307 | + const std::string &keyname, |
2308 | + const VariantTypes &value) = 0; |
2309 | virtual CCSSettingType & type () = 0; |
2310 | virtual std::string & keyname () = 0; |
2311 | virtual SetWriteExpectation & setWriteExpectationAndWrite () = 0; |
2312 | @@ -516,7 +649,7 @@ |
2313 | |
2314 | typedef boost::shared_ptr <CCSBackendConceptTestParam <I> > Ptr; |
2315 | |
2316 | - CCSBackendConceptTestParam (CCSBackendConceptTestEnvironmentInterface *testEnv, |
2317 | + CCSBackendConceptTestParam (CCSBackendConceptTestEnvironmentFactoryInterface *testEnvFactory, |
2318 | const VariantTypes &value, |
2319 | const NativeWriteMethod &write, |
2320 | const CCSSettingType &type, |
2321 | @@ -524,7 +657,8 @@ |
2322 | const SetReadExpectation &setReadExpectation, |
2323 | const SetWriteExpectation &setWriteExpectation, |
2324 | const std::string &what) : |
2325 | - mTestEnv (testEnv), |
2326 | + mTestEnvFactory (testEnvFactory), |
2327 | + mTestEnv (), |
2328 | mValue (value), |
2329 | mNativeWrite (write), |
2330 | mType (type), |
2331 | @@ -535,9 +669,30 @@ |
2332 | { |
2333 | } |
2334 | |
2335 | - CCSBackendConceptTestEnvironmentInterface * testEnv () { return mTestEnv; } |
2336 | + void TearDown (CCSBackend *b) |
2337 | + { |
2338 | + if (mTestEnv) |
2339 | + mTestEnv->TearDown (b); |
2340 | + |
2341 | + mTestEnv.reset (); |
2342 | + } |
2343 | + |
2344 | + CCSBackendConceptTestEnvironmentInterface::Ptr testEnv () |
2345 | + { |
2346 | + if (!mTestEnv) |
2347 | + mTestEnv = mTestEnvFactory->ConstructTestEnv (); |
2348 | + |
2349 | + return mTestEnv; |
2350 | + } |
2351 | + |
2352 | VariantTypes & value () { return mValue; } |
2353 | - CCSBackendConceptTestParamInterface::NativeWriteMethod & nativeWrite () { return mNativeWrite; } |
2354 | + void nativeWrite (const CCSBackendConceptTestEnvironmentInterface::Ptr & iface, |
2355 | + const std::string &plugin, |
2356 | + const std::string &keyname, |
2357 | + const VariantTypes &value) |
2358 | + { |
2359 | + return ((iface.get ())->*mNativeWrite) (plugin, keyname, value); |
2360 | + } |
2361 | CCSSettingType & type () { return mType; } |
2362 | std::string & keyname () { return mKeyname; } |
2363 | CCSBackendConceptTestParamInterface::SetReadExpectation & setReadExpectation () { return mSetReadExpectation; } |
2364 | @@ -546,7 +701,8 @@ |
2365 | |
2366 | private: |
2367 | |
2368 | - CCSBackendConceptTestEnvironmentInterface *mTestEnv; |
2369 | + CCSBackendConceptTestEnvironmentFactoryInterface *mTestEnvFactory; |
2370 | + CCSBackendConceptTestEnvironmentInterface::Ptr mTestEnv; |
2371 | VariantTypes mValue; |
2372 | NativeWriteMethod mNativeWrite; |
2373 | CCSSettingType mType; |
2374 | @@ -586,7 +742,7 @@ |
2375 | |
2376 | virtual void TearDown () |
2377 | { |
2378 | - CCSBackendConformanceTest::GetParam ()->testEnv ()->TearDown (mBackend); |
2379 | + CCSBackendConformanceTest::GetParam ()->TearDown (mBackend); |
2380 | |
2381 | for (std::list <CCSContext *>::iterator it = mSpawnedContexts.begin (); |
2382 | it != mSpawnedContexts.end (); |
2383 | @@ -640,6 +796,7 @@ |
2384 | { |
2385 | *setting = ccsMockSettingNew (); |
2386 | mSpawnedSettings.push_back (*setting); |
2387 | + mSpawnedSettingInfo.push_back (CCSSettingInfo ()); |
2388 | |
2389 | CCSSettingGMock *gmockSetting = (CCSSettingGMock *) ccsObjectGetPrivate (*setting); |
2390 | |
2391 | @@ -650,6 +807,7 @@ |
2392 | ON_CALL (*gmockSetting, getName ()).WillByDefault (Return ((char *) name.c_str ())); |
2393 | ON_CALL (*gmockSetting, getType ()).WillByDefault (Return (type)); |
2394 | ON_CALL (*gmockSetting, getParent ()).WillByDefault (Return (plugin)); |
2395 | + ON_CALL (*gmockSetting, getInfo ()).WillByDefault (Return (&(mSpawnedSettingInfo.back ()))); |
2396 | } |
2397 | |
2398 | protected: |
2399 | @@ -662,6 +820,7 @@ |
2400 | std::list <CCSContext *> mSpawnedContexts; |
2401 | std::list <CCSPlugin *> mSpawnedPlugins; |
2402 | std::list <CCSSetting *> mSpawnedSettings; |
2403 | + std::vector <CCSSettingInfo> mSpawnedSettingInfo; |
2404 | |
2405 | CCSBackend *mBackend; |
2406 | |
2407 | @@ -680,155 +839,209 @@ |
2408 | float floatValues[] = { 1.0, 2.0, 3.0 }; |
2409 | const char * stringValues[] = { "foo", "grill", "bar" }; |
2410 | |
2411 | -CCSSettingColorValue colorValues[3] = { { .color = { 100, 200, 300, 100 } }, |
2412 | - { .color = { 50, 100, 200, 300 } }, |
2413 | - { .color = { 10, 20, 30, 40 } } |
2414 | - }; |
2415 | - |
2416 | -CCSSettingKeyValue keyValue = { (1 << 0) | (1 << 1), |
2417 | - 1 }; |
2418 | - |
2419 | -CCSSettingButtonValue buttonValue = { (1 << 0) | (1 << 1), |
2420 | - 1, |
2421 | +const unsigned int NUM_COLOR_VALUES = 3; |
2422 | + |
2423 | +CCSSettingColorValue * |
2424 | +getColorValueList () |
2425 | +{ |
2426 | + static const unsigned short max = std::numeric_limits <unsigned short>::max (); |
2427 | + static const unsigned short maxD2 = max / 2; |
2428 | + static const unsigned short maxD4 = max / 4; |
2429 | + static const unsigned short maxD8 = max / 8; |
2430 | + |
2431 | + static CCSSettingColorValue colorValues[NUM_COLOR_VALUES] = { { .color = { maxD2, maxD4, maxD8, max } }, |
2432 | + { .color = { maxD8, maxD4, maxD2, max } }, |
2433 | + { .color = { max, maxD4, maxD2, maxD8 } } |
2434 | + }; |
2435 | + static bool colorValueListInitialized = false; |
2436 | + |
2437 | + if (!colorValueListInitialized) |
2438 | + { |
2439 | + for (unsigned int i = 0; i < NUM_COLOR_VALUES; i++) |
2440 | + { |
2441 | + CharacterWrapper s (ccsColorToString (&colorValues[i])); |
2442 | + |
2443 | + ccsStringToColor (s, &colorValues[i]); |
2444 | + } |
2445 | + |
2446 | + colorValueListInitialized = true; |
2447 | + } |
2448 | + |
2449 | + return colorValues; |
2450 | +} |
2451 | + |
2452 | +CCSSettingKeyValue keyValue = { XK_A, |
2453 | + (1 << 0)}; |
2454 | + |
2455 | +CCSSettingButtonValue buttonValue = { 1, |
2456 | + (1 << 0), |
2457 | (1 << 1) }; |
2458 | + |
2459 | +} |
2460 | + |
2461 | +typedef boost::function <CCSSettingValueList (CCSSetting *)> ConstructorFunc; |
2462 | + |
2463 | +CCSListWrapper::Ptr |
2464 | +CCSListConstructionExpectationsSetter (const ConstructorFunc &c, |
2465 | + CCSSettingType type, |
2466 | + bool freeItems) |
2467 | +{ |
2468 | + boost::function <void (CCSSetting *)> f (boost::bind (ccsFreeMockSetting, _1)); |
2469 | + boost::shared_ptr <CCSSetting> mockSetting (ccsMockSettingNew (), f); |
2470 | + CCSSettingGMock *gmockSetting = reinterpret_cast <CCSSettingGMock *> (ccsObjectGetPrivate (mockSetting.get ())); |
2471 | + |
2472 | + EXPECT_CALL (*gmockSetting, getType ()).WillRepeatedly (Return (TypeList)); |
2473 | + |
2474 | + boost::shared_ptr <CCSSettingInfo> listInfo (new CCSSettingInfo); |
2475 | + |
2476 | + listInfo->forList.listType = type; |
2477 | + |
2478 | + EXPECT_CALL (*gmockSetting, getInfo ()).WillRepeatedly (Return (listInfo.get ())); |
2479 | + EXPECT_CALL (*gmockSetting, getDefaultValue ()).WillRepeatedly (ReturnNull ()); |
2480 | + return boost::make_shared <CCSListWrapper> (c (mockSetting.get ()), freeItems, type, listInfo, mockSetting); |
2481 | } |
2482 | |
2483 | template <typename I> |
2484 | ::testing::internal::ParamGenerator<typename CCSBackendConceptTestParamInterface::Ptr> |
2485 | GenerateTestingParametersForBackendInterface () |
2486 | { |
2487 | - static I interface; |
2488 | - static CCSBackendConceptTestEnvironmentInterface *backendEnv = &interface; |
2489 | + static CCSBackendConceptTestEnvironmentFactory <I> interfaceFactory; |
2490 | + static CCSBackendConceptTestEnvironmentFactoryInterface *backendEnvFactory = &interfaceFactory; |
2491 | |
2492 | typedef CCSBackendConceptTestParam<I> ConceptParam; |
2493 | |
2494 | static typename CCSBackendConceptTestParamInterface::Ptr testParam[] = |
2495 | { |
2496 | - boost::make_shared <ConceptParam> (backendEnv, |
2497 | + boost::make_shared <ConceptParam> (backendEnvFactory, |
2498 | VariantTypes (1), |
2499 | - boost::bind (&CCSBackendConceptTestEnvironmentInterface::WriteIntegerAtKey, backendEnv, _1, _2, _3), |
2500 | + &CCSBackendConceptTestEnvironmentInterface::WriteIntegerAtKey, |
2501 | TypeInt, |
2502 | "integer_setting", |
2503 | boost::bind (SetIntReadExpectation, _1, _2), |
2504 | boost::bind (SetIntWriteExpectation, _1, _2, _3, _4, _5, _6), |
2505 | "TestInt"), |
2506 | - boost::make_shared <ConceptParam> (backendEnv, |
2507 | + boost::make_shared <ConceptParam> (backendEnvFactory, |
2508 | VariantTypes (true), |
2509 | - boost::bind (&CCSBackendConceptTestEnvironmentInterface::WriteBoolAtKey, backendEnv, _1, _2, _3), |
2510 | + &CCSBackendConceptTestEnvironmentInterface::WriteBoolAtKey, |
2511 | TypeBool, |
2512 | "boolean_setting", |
2513 | boost::bind (SetBoolReadExpectation, _1, _2), |
2514 | boost::bind (SetBoolWriteExpectation, _1, _2, _3, _4, _5, _6), |
2515 | "TestBool"), |
2516 | - boost::make_shared <ConceptParam> (backendEnv, |
2517 | + boost::make_shared <ConceptParam> (backendEnvFactory, |
2518 | VariantTypes (static_cast <float> (3.0)), |
2519 | - boost::bind (&CCSBackendConceptTestEnvironmentInterface::WriteFloatAtKey, backendEnv, _1, _2, _3), |
2520 | + &CCSBackendConceptTestEnvironmentInterface::WriteFloatAtKey, |
2521 | TypeFloat, |
2522 | "float_setting", |
2523 | boost::bind (SetFloatReadExpectation, _1, _2), |
2524 | boost::bind (SetFloatWriteExpectation, _1, _2, _3, _4, _5, _6), |
2525 | "TestFloat"), |
2526 | - boost::make_shared <ConceptParam> (backendEnv, |
2527 | + boost::make_shared <ConceptParam> (backendEnvFactory, |
2528 | VariantTypes (static_cast <const char *> ("foo")), |
2529 | - boost::bind (&CCSBackendConceptTestEnvironmentInterface::WriteStringAtKey, backendEnv, _1, _2, _3), |
2530 | + &CCSBackendConceptTestEnvironmentInterface::WriteStringAtKey, |
2531 | TypeString, |
2532 | "string_setting", |
2533 | boost::bind (SetStringReadExpectation, _1, _2), |
2534 | boost::bind (SetStringWriteExpectation, _1, _2, _3, _4, _5, _6), |
2535 | "TestString"), |
2536 | - boost::make_shared <ConceptParam> (backendEnv, |
2537 | + boost::make_shared <ConceptParam> (backendEnvFactory, |
2538 | VariantTypes (static_cast <const char *> ("foo=bar")), |
2539 | - boost::bind (&CCSBackendConceptTestEnvironmentInterface::WriteMatchAtKey, backendEnv, _1, _2, _3), |
2540 | + &CCSBackendConceptTestEnvironmentInterface::WriteMatchAtKey, |
2541 | TypeMatch, |
2542 | "match_setting", |
2543 | boost::bind (SetMatchReadExpectation, _1, _2), |
2544 | boost::bind (SetMatchWriteExpectation, _1, _2, _3, _4, _5, _6), |
2545 | "TestMatch"), |
2546 | - boost::make_shared <ConceptParam> (backendEnv, |
2547 | + boost::make_shared <ConceptParam> (backendEnvFactory, |
2548 | VariantTypes (true), |
2549 | - boost::bind (&CCSBackendConceptTestEnvironmentInterface::WriteBellAtKey, backendEnv, _1, _2, _3), |
2550 | + &CCSBackendConceptTestEnvironmentInterface::WriteBellAtKey, |
2551 | TypeBell, |
2552 | "bell_setting", |
2553 | boost::bind (SetBellReadExpectation, _1, _2), |
2554 | boost::bind (SetBellWriteExpectation, _1, _2, _3, _4, _5, _6), |
2555 | "TestBell"), |
2556 | - boost::make_shared <ConceptParam> (backendEnv, |
2557 | - VariantTypes (impl::colorValues[0]), |
2558 | - boost::bind (&CCSBackendConceptTestEnvironmentInterface::WriteColorAtKey, backendEnv, _1, _2, _3), |
2559 | + boost::make_shared <ConceptParam> (backendEnvFactory, |
2560 | + VariantTypes (impl::getColorValueList ()[0]), |
2561 | + &CCSBackendConceptTestEnvironmentInterface::WriteColorAtKey, |
2562 | TypeColor, |
2563 | "color_setting", |
2564 | boost::bind (SetColorReadExpectation, _1, _2), |
2565 | boost::bind (SetColorWriteExpectation, _1, _2, _3, _4, _5, _6), |
2566 | "TestColor"), |
2567 | - boost::make_shared <ConceptParam> (backendEnv, |
2568 | + boost::make_shared <ConceptParam> (backendEnvFactory, |
2569 | VariantTypes (impl::keyValue), |
2570 | - boost::bind (&CCSBackendConceptTestEnvironmentInterface::WriteKeyAtKey, backendEnv, _1, _2, _3), |
2571 | + &CCSBackendConceptTestEnvironmentInterface::WriteKeyAtKey, |
2572 | TypeKey, |
2573 | "key_setting", |
2574 | boost::bind (SetKeyReadExpectation, _1, _2), |
2575 | boost::bind (SetKeyWriteExpectation, _1, _2, _3, _4, _5, _6), |
2576 | "TestKey"), |
2577 | - boost::make_shared <ConceptParam> (backendEnv, |
2578 | + boost::make_shared <ConceptParam> (backendEnvFactory, |
2579 | VariantTypes (impl::buttonValue), |
2580 | - boost::bind (&CCSBackendConceptTestEnvironmentInterface::WriteButtonAtKey, backendEnv, _1, _2, _3), |
2581 | + &CCSBackendConceptTestEnvironmentInterface::WriteButtonAtKey, |
2582 | TypeButton, |
2583 | "button_setting", |
2584 | boost::bind (SetButtonReadExpectation, _1, _2), |
2585 | boost::bind (SetButtonWriteExpectation, _1, _2, _3, _4, _5, _6), |
2586 | "TestButton"), |
2587 | - boost::make_shared <ConceptParam> (backendEnv, |
2588 | + boost::make_shared <ConceptParam> (backendEnvFactory, |
2589 | VariantTypes (static_cast <unsigned int> (1)), |
2590 | - boost::bind (&CCSBackendConceptTestEnvironmentInterface::WriteEdgeAtKey, backendEnv, _1, _2, _3), |
2591 | + &CCSBackendConceptTestEnvironmentInterface::WriteEdgeAtKey, |
2592 | TypeEdge, |
2593 | "edge_setting", |
2594 | boost::bind (SetEdgeReadExpectation, _1, _2), |
2595 | boost::bind (SetEdgeWriteExpectation, _1, _2, _3, _4, _5, _6), |
2596 | "TestEdge"), |
2597 | - boost::make_shared <ConceptParam> (backendEnv, |
2598 | - VariantTypes (boost::make_shared <CCSListWrapper> (ccsGetValueListFromIntArray (impl::intValues, |
2599 | - sizeof (impl::intValues) / sizeof (impl::intValues[0]), |
2600 | - NULL), false, TypeInt)), |
2601 | - boost::bind (&CCSBackendConceptTestEnvironmentInterface::WriteListAtKey, backendEnv, _1, _2, _3), |
2602 | + boost::make_shared <ConceptParam> (backendEnvFactory, |
2603 | + VariantTypes (CCSListConstructionExpectationsSetter (boost::bind (ccsGetValueListFromIntArray, |
2604 | + impl::intValues, |
2605 | + sizeof (impl::intValues) / sizeof (impl::intValues[0]), _1), |
2606 | + TypeInt, true)), |
2607 | + &CCSBackendConceptTestEnvironmentInterface::WriteListAtKey, |
2608 | TypeList, |
2609 | "int_list_setting", |
2610 | boost::bind (SetListReadExpectation, _1, _2), |
2611 | boost::bind (SetListWriteExpectation, _1, _2, _3, _4, _5, _6), |
2612 | "TestListInt"), |
2613 | - boost::make_shared <ConceptParam> (backendEnv, |
2614 | - VariantTypes (boost::make_shared <CCSListWrapper> (ccsGetValueListFromFloatArray (impl::floatValues, |
2615 | - sizeof (impl::floatValues) / sizeof (impl::floatValues[0]), |
2616 | - NULL), false, TypeFloat)), |
2617 | - boost::bind (&CCSBackendConceptTestEnvironmentInterface::WriteListAtKey, backendEnv, _1, _2, _3), |
2618 | + boost::make_shared <ConceptParam> (backendEnvFactory, |
2619 | + VariantTypes (CCSListConstructionExpectationsSetter (boost::bind (ccsGetValueListFromFloatArray, |
2620 | + impl::floatValues, |
2621 | + sizeof (impl::floatValues) / sizeof (impl::floatValues[0]), _1), |
2622 | + TypeFloat, true)), |
2623 | + &CCSBackendConceptTestEnvironmentInterface::WriteListAtKey, |
2624 | TypeList, |
2625 | "float_list_setting", |
2626 | boost::bind (SetListReadExpectation, _1, _2), |
2627 | boost::bind (SetListWriteExpectation, _1, _2, _3, _4, _5, _6), |
2628 | - "TestListInt"), |
2629 | - boost::make_shared <ConceptParam> (backendEnv, |
2630 | - VariantTypes (boost::make_shared <CCSListWrapper> (ccsGetValueListFromBoolArray (impl::boolValues, |
2631 | - sizeof (impl::boolValues) / sizeof (impl::boolValues[0]), |
2632 | - NULL), false, TypeBool)), |
2633 | - boost::bind (&CCSBackendConceptTestEnvironmentInterface::WriteListAtKey, backendEnv, _1, _2, _3), |
2634 | + "TestListFloat"), |
2635 | + boost::make_shared <ConceptParam> (backendEnvFactory, |
2636 | + VariantTypes (CCSListConstructionExpectationsSetter (boost::bind (ccsGetValueListFromBoolArray, |
2637 | + impl::boolValues, |
2638 | + sizeof (impl::boolValues) / sizeof (impl::boolValues[0]), _1), |
2639 | + TypeBool, true)), |
2640 | + &CCSBackendConceptTestEnvironmentInterface::WriteListAtKey, |
2641 | TypeList, |
2642 | "bool_list_setting", |
2643 | boost::bind (SetListReadExpectation, _1, _2), |
2644 | boost::bind (SetListWriteExpectation, _1, _2, _3, _4, _5, _6), |
2645 | "TestListBool"), |
2646 | - boost::make_shared <ConceptParam> (backendEnv, |
2647 | - VariantTypes (boost::make_shared <CCSListWrapper> (ccsGetValueListFromStringArray (impl::stringValues, |
2648 | - sizeof (impl::stringValues) / sizeof (impl::stringValues[0]), |
2649 | - NULL), false, TypeString)), |
2650 | - boost::bind (&CCSBackendConceptTestEnvironmentInterface::WriteListAtKey, backendEnv, _1, _2, _3), |
2651 | + boost::make_shared <ConceptParam> (backendEnvFactory, |
2652 | + VariantTypes (CCSListConstructionExpectationsSetter (boost::bind (ccsGetValueListFromStringArray, |
2653 | + impl::stringValues, |
2654 | + sizeof (impl::stringValues) / sizeof (impl::stringValues[0]), _1), |
2655 | + TypeString, true)), |
2656 | + &CCSBackendConceptTestEnvironmentInterface::WriteListAtKey, |
2657 | TypeList, |
2658 | "string_list_setting", |
2659 | boost::bind (SetListReadExpectation, _1, _2), |
2660 | boost::bind (SetListWriteExpectation, _1, _2, _3, _4, _5, _6), |
2661 | "TestListString"), |
2662 | - boost::make_shared <ConceptParam> (backendEnv, |
2663 | - VariantTypes (boost::make_shared <CCSListWrapper> (ccsGetValueListFromColorArray (impl::colorValues, |
2664 | - sizeof (impl::colorValues) / sizeof (impl::colorValues[0]), |
2665 | - NULL), false, TypeColor)), |
2666 | - boost::bind (&CCSBackendConceptTestEnvironmentInterface::WriteListAtKey, backendEnv, _1, _2, _3), |
2667 | + boost::make_shared <ConceptParam> (backendEnvFactory, |
2668 | + VariantTypes (CCSListConstructionExpectationsSetter (boost::bind (ccsGetValueListFromColorArray, |
2669 | + impl::getColorValueList (), |
2670 | + impl::NUM_COLOR_VALUES, _1), |
2671 | + TypeColor, true)), |
2672 | + &CCSBackendConceptTestEnvironmentInterface::WriteListAtKey, |
2673 | TypeList, |
2674 | "color_list_setting", |
2675 | boost::bind (SetListReadExpectation, _1, _2), |
2676 | @@ -885,31 +1098,62 @@ |
2677 | SCOPED_TRACE (CCSBackendConformanceTest::GetParam ()->what () + "Read"); |
2678 | |
2679 | CCSBackendConformanceTest::GetParam ()->testEnv ()->PreRead (gmockContext, gmockPlugin, gmockSetting, GetParam ()->type ()); |
2680 | - CCSBackendConformanceTest::GetParam ()->nativeWrite () (pluginName, settingName, VALUE); |
2681 | + CCSBackendConformanceTest::GetParam ()->nativeWrite (CCSBackendConformanceTest::GetParam ()->testEnv (), |
2682 | + pluginName, settingName, VALUE); |
2683 | CCSBackendConformanceTest::GetParam ()->testEnv ()->PostRead (gmockContext, gmockPlugin, gmockSetting, GetParam ()->type ()); |
2684 | CCSBackendConformanceTest::GetParam ()->setReadExpectation () (gmockSetting, VALUE); |
2685 | |
2686 | ccsBackendReadSetting (CCSBackendConformanceTest::GetBackend (), context, setting); |
2687 | } |
2688 | |
2689 | +TEST_P (CCSBackendConformanceTestReadWrite, TestUpdateMockedValue) |
2690 | +{ |
2691 | + SCOPED_TRACE (CCSBackendConformanceTest::GetParam ()->what () + "UpdateMocked"); |
2692 | + |
2693 | + CCSBackendConformanceTest::GetParam ()->testEnv ()->PreUpdate (gmockContext, gmockPlugin, gmockSetting, GetParam ()->type ()); |
2694 | + CCSBackendConformanceTest::GetParam ()->nativeWrite (CCSBackendConformanceTest::GetParam ()->testEnv (), |
2695 | + pluginName, settingName, VALUE); |
2696 | + CCSBackendConformanceTest::GetParam ()->testEnv ()->PostUpdate (gmockContext, gmockPlugin, gmockSetting, GetParam ()->type ()); |
2697 | + CCSBackendConformanceTest::GetParam ()->setReadExpectation () (gmockSetting, VALUE); |
2698 | + |
2699 | + ccsBackendUpdateSetting (CCSBackendConformanceTest::GetBackend (), context, plugin, setting); |
2700 | +} |
2701 | + |
2702 | +TEST_P (CCSBackendConformanceTestReadWrite, TestUpdateKeyedValue) |
2703 | +{ |
2704 | + SCOPED_TRACE (CCSBackendConformanceTest::GetParam ()->what () + "UpdateMocked"); |
2705 | + |
2706 | + CCSBackendConformanceTest::GetParam ()->testEnv ()->PreUpdate (gmockContext, gmockPlugin, gmockSetting, GetParam ()->type ()); |
2707 | + CCSBackendConformanceTest::GetParam ()->nativeWrite (CCSBackendConformanceTest::GetParam ()->testEnv (), |
2708 | + pluginName, settingName, VALUE); |
2709 | + CCSBackendConformanceTest::GetParam ()->testEnv ()->PostUpdate (gmockContext, gmockPlugin, gmockSetting, GetParam ()->type ()); |
2710 | + CCSBackendConformanceTest::GetParam ()->setReadExpectation () (gmockSetting, VALUE); |
2711 | + |
2712 | + EXPECT_CALL (*gmockContext, findPlugin (_)).WillOnce (Return (plugin)); |
2713 | + EXPECT_CALL (*gmockPlugin, findSetting (_)).WillOnce (Return (setting)); |
2714 | + |
2715 | + EXPECT_TRUE (CCSBackendConformanceTest::GetParam ()->testEnv ()->UpdateSettingAtKey (pluginName, settingName)); |
2716 | +} |
2717 | + |
2718 | TEST_P (CCSBackendConformanceTestReadWrite, TestWriteValue) |
2719 | { |
2720 | SCOPED_TRACE (CCSBackendConformanceTest::GetParam ()->what () + "Write"); |
2721 | |
2722 | CCSBackendConformanceTest::GetParam ()->testEnv ()->PreWrite (gmockContext, gmockPlugin, gmockSetting, GetParam ()->type ()); |
2723 | CCSBackendConformanceTest::GetParam ()->setWriteExpectationAndWrite () (pluginName, |
2724 | - settingName, |
2725 | - VALUE, |
2726 | - setting, |
2727 | - boost::bind (ccsBackendWriteSetting, |
2728 | - CCSBackendConformanceTest::GetBackend (), |
2729 | - context, |
2730 | - setting), |
2731 | - GetParam ()->testEnv ()); |
2732 | + settingName, |
2733 | + VALUE, |
2734 | + setting, |
2735 | + boost::bind (ccsBackendWriteSetting, |
2736 | + CCSBackendConformanceTest::GetBackend (), |
2737 | + context, |
2738 | + setting), |
2739 | + GetParam ()->testEnv ()); |
2740 | CCSBackendConformanceTest::GetParam ()->testEnv ()->PostWrite (gmockContext, gmockPlugin, gmockSetting, GetParam ()->type ()); |
2741 | |
2742 | } |
2743 | |
2744 | |
2745 | + |
2746 | #endif |
2747 |