Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

portals: Support wallpaper #262

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/models/portals.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,13 @@ var FlatpakPortalsModel = GObject.registerClass({
this._notificationsSupported = null;
this._devicesSupported = null;
this._locationSupported = null;
this._wallpaperSupported = null;

this._backgroundReason = '';
this._notificationReason = '';
this._devicesReason = '';
this._locationReason = '';
this._wallpaperReason = '';

this._info = info.getDefault();
this._appId = '';
Expand Down Expand Up @@ -152,6 +154,16 @@ var FlatpakPortalsModel = GObject.registerClass({
allowed: ['EXACT', '0'],
disallowed: ['NONE', '0'],
},
'portals-wallpaper': {
supported: this.isSupported('wallpaper'),
description: _('Wallpaper'),
value: this.constructor.getDefault(),
example: _('Can change your background and lockscreen wallpapers'),
table: 'wallpaper',
id: 'wallpaper',
allowed: ['yes'],
disallowed: ['no'],
},
};
}

Expand Down
3 changes: 3 additions & 0 deletions tests/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ class MockPermissionsStore {
location: {
location: {},
},
wallpaper: {
wallpaper: {},
},
};

this._version = new GLib.Variant('u', 2);
Expand Down
12 changes: 11 additions & 1 deletion tests/src/testModels.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const {

setup();

const _totalPermissions = 36;
const _totalPermissions = 37;

const _basicAppId = 'com.test.Basic';
const _oldAppId = 'com.test.Old';
Expand Down Expand Up @@ -774,13 +774,17 @@ describe('Model', function() {
expect(permissions.portals_location).toBe(false);
permissions.set_property('portals_location', true);

expect(permissions.portals_wallpaper).toBe(false);
permissions.set_property('portals_wallpaper', true);

GLib.timeout_add(GLib.PRIORITY_HIGH, delay + 1, () => {
expect(getValueFromService('background', 'background', 'yes', _basicAppId)).toBe(true);
expect(getValueFromService('notifications', 'notification', 'yes', _basicAppId)).toBe(true);
expect(getValueFromService('devices', 'microphone', 'yes', _basicAppId)).toBe(true);
expect(getValueFromService('devices', 'speakers', 'yes', _basicAppId)).toBe(true);
expect(getValueFromService('devices', 'camera', 'yes', _basicAppId)).toBe(true);
expect(getValueFromService('location', 'location', 'EXACT', _basicAppId)).toBe(true);
expect(getValueFromService('wallpaper', 'wallpaper', 'yes', _basicAppId)).toBe(true);

done();
return GLib.SOURCE_REMOVE;
Expand All @@ -800,6 +804,7 @@ describe('Model', function() {
expect(getValueFromService('devices', 'speakers', 'no', _basicAppId)).toBe(true);
expect(getValueFromService('devices', 'camera', 'no', _basicAppId)).toBe(true);
expect(getValueFromService('location', 'location', 'NONE', _basicAppId)).toBe(true);
expect(getValueFromService('wallpaper', 'wallpaper', 'no', _basicAppId)).toBe(true);
});


Expand All @@ -813,13 +818,15 @@ describe('Model', function() {
expect(permissions.portals_speakers).toBe(false);
expect(permissions.portals_camera).toBe(false);
expect(permissions.portals_location).toBe(false);
expect(permissions.portals_wallpaper).toBe(false);

permissions.set_property('portals_notification', true);
permissions.set_property('portals_background', true);
permissions.set_property('portals_microphone', true);
permissions.set_property('portals_speakers', true);
permissions.set_property('portals_camera', true);
permissions.set_property('portals_location', true);
permissions.set_property('portals_wallpaper', true);

GLib.timeout_add(GLib.PRIORITY_HIGH, delay + 1, () => {
expect(getValueFromService('background', 'background', 'yes', _overridenAppId)).toBe(true);
Expand All @@ -828,6 +835,7 @@ describe('Model', function() {
expect(getValueFromService('devices', 'speakers', 'yes', _overridenAppId)).toBe(true);
expect(getValueFromService('devices', 'camera', 'yes', _overridenAppId)).toBe(true);
expect(getValueFromService('location', 'location', 'EXACT', _overridenAppId)).toBe(true);
expect(getValueFromService('wallpaper', 'wallpaper', 'yes', _overridenAppId)).toBe(true);

permissions.reset();

Expand All @@ -837,6 +845,7 @@ describe('Model', function() {
expect(getValueFromService('devices', 'speakers', 'no', _overridenAppId)).toBe(true);
expect(getValueFromService('devices', 'camera', 'no', _overridenAppId)).toBe(true);
expect(getValueFromService('location', 'location', 'NONE', _overridenAppId)).toBe(true);
expect(getValueFromService('wallpaper', 'wallpaper', 'no', _overridenAppId)).toBe(true);

permissions.undo();

Expand All @@ -846,6 +855,7 @@ describe('Model', function() {
expect(getValueFromService('devices', 'speakers', 'yes', _overridenAppId)).toBe(true);
expect(getValueFromService('devices', 'camera', 'yes', _overridenAppId)).toBe(true);
expect(getValueFromService('location', 'location', 'EXACT', _overridenAppId)).toBe(true);
expect(getValueFromService('wallpaper', 'wallpaper', 'yes', _overridenAppId)).toBe(true);

done();
return GLib.SOURCE_REMOVE;
Expand Down