aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorFerdinand Thiessen <opensource@fthiessen.de>2024-01-20 07:43:04 +0100
committerFerdinand Thiessen <opensource@fthiessen.de>2024-05-21 20:36:26 +0200
commit538a04968a24f645b12ca2647952a5b73ebc3eac (patch)
treefe6de92830c3cab15b8e2ea96e473566267726c7 /apps
parent11dbfa636d746eac4a82460d0677dc6ffe98f068 (diff)
downloadnextcloud-server-538a04968a24f645b12ca2647952a5b73ebc3eac.tar.gz
nextcloud-server-538a04968a24f645b12ca2647952a5b73ebc3eac.zip
fix(tests): Adjust theming test for new splitted background and primary colors
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
Diffstat (limited to 'apps')
-rw-r--r--apps/settings/src/components/AdminAI.vue6
-rw-r--r--apps/theming/css/default.css2
-rw-r--r--apps/theming/lib/Service/BackgroundService.php5
-rw-r--r--apps/theming/lib/Themes/CommonThemeTrait.php3
-rw-r--r--apps/theming/lib/Util.php2
-rw-r--r--apps/theming/openapi.json4
-rw-r--r--apps/theming/tests/Settings/PersonalTest.php14
-rw-r--r--apps/theming/tests/ThemingDefaultsTest.php74
8 files changed, 34 insertions, 76 deletions
diff --git a/apps/settings/src/components/AdminAI.vue b/apps/settings/src/components/AdminAI.vue
index ea444fc25cf..5b71bb0dc04 100644
--- a/apps/settings/src/components/AdminAI.vue
+++ b/apps/settings/src/components/AdminAI.vue
@@ -190,9 +190,9 @@ export default {
.draggable__number {
border-radius: 20px;
- border: 2px solid var(--color-primary-default);
- color: var(--color-primary-default);
- padding: 0px 7px;
+ border: 2px solid var(--color-primary-element);
+ color: var(--color-primary-element);
+ padding: 0px 7px;
margin-right: 3px;
}
diff --git a/apps/theming/css/default.css b/apps/theming/css/default.css
index c96e41d23fc..6a5f91af864 100644
--- a/apps/theming/css/default.css
+++ b/apps/theming/css/default.css
@@ -71,7 +71,6 @@
--primary-invert-if-bright: no;
--primary-invert-if-dark: invert(100%);
--color-primary: #00679e;
- --color-primary-default: #0082c9;
--color-primary-text: #ffffff;
--color-primary-hover: #3285b1;
--color-primary-light: #e5eff5;
@@ -87,4 +86,5 @@
--gradient-primary-background: linear-gradient(40deg, var(--color-primary) 0%, var(--color-primary-hover) 100%);
--color-background-plain: #00679e;
--color-background-plain-text: #ffffff;
+ --image-background: url('/apps/theming/img/background/kamil-porembinski-clouds.jpg');
}
diff --git a/apps/theming/lib/Service/BackgroundService.php b/apps/theming/lib/Service/BackgroundService.php
index c323a721b60..cdaff2372a8 100644
--- a/apps/theming/lib/Service/BackgroundService.php
+++ b/apps/theming/lib/Service/BackgroundService.php
@@ -43,7 +43,7 @@ use OCP\Lock\LockedException;
use OCP\PreConditionNotMetException;
class BackgroundService {
- public const DEFAULT_COLOR = '#0082c9';
+ public const DEFAULT_COLOR = '#00679e';
public const DEFAULT_BACKGROUND_COLOR = '#00679e';
/**
@@ -300,9 +300,10 @@ class BackgroundService {
$meanColor = $this->calculateMeanColor($image);
if ($meanColor !== false) {
$this->config->setAppValue(Application::APP_ID, 'background_color', $meanColor);
+ return $meanColor;
}
- return $meanColor;
}
+ return null;
}
/**
diff --git a/apps/theming/lib/Themes/CommonThemeTrait.php b/apps/theming/lib/Themes/CommonThemeTrait.php
index bdf95d98275..f2d86009cef 100644
--- a/apps/theming/lib/Themes/CommonThemeTrait.php
+++ b/apps/theming/lib/Themes/CommonThemeTrait.php
@@ -61,7 +61,6 @@ trait CommonThemeTrait {
'--primary-invert-if-dark' => $this->util->invertTextColor($colorPrimaryElement) ? 'no' : 'invert(100%)',
'--color-primary' => $this->primaryColor,
- '--color-primary-default' => $this->defaultPrimaryColor,
'--color-primary-text' => $this->util->invertTextColor($this->primaryColor) ? '#000000' : '#ffffff',
'--color-primary-hover' => $this->util->mix($this->primaryColor, $colorMainBackground, 60),
'--color-primary-light' => $colorPrimaryLight,
@@ -105,7 +104,7 @@ trait CommonThemeTrait {
if ($this->imageManager->hasImage($image)) {
$imageUrl = $this->imageManager->getImageUrl($image);
$variables["--image-$image"] = "url('" . $imageUrl . "')";
- } else if ($image === 'background') {
+ } elseif ($image === 'background') {
// Apply default background if nothing is configured
$variables['--image-background'] = "url('" . $this->themingDefaults->getBackground() . "')";
}
diff --git a/apps/theming/lib/Util.php b/apps/theming/lib/Util.php
index a2f8ee0abad..5dd71c1c1d3 100644
--- a/apps/theming/lib/Util.php
+++ b/apps/theming/lib/Util.php
@@ -93,7 +93,7 @@ class Util {
$contrast = $this->colorContrast($color, $blurredBackground);
// Min. element contrast is 3:1 but we need to keep hover states in mind -> min 3.2:1
- $minContrast = $highContrast ? 5.5 : 3.2;
+ $minContrast = $highContrast ? 5.6 : 3.2;
while ($contrast < $minContrast && $iteration++ < 100) {
$hsl = Color::hexToHsl($color);
diff --git a/apps/theming/openapi.json b/apps/theming/openapi.json
index 072b1897f69..fe0f342f993 100644
--- a/apps/theming/openapi.json
+++ b/apps/theming/openapi.json
@@ -63,6 +63,7 @@
"color-element-dark",
"logo",
"background",
+ "background-text",
"background-plain",
"background-default",
"logoheader",
@@ -99,6 +100,9 @@
"background": {
"type": "string"
},
+ "background-text": {
+ "type": "string"
+ },
"background-plain": {
"type": "boolean"
},
diff --git a/apps/theming/tests/Settings/PersonalTest.php b/apps/theming/tests/Settings/PersonalTest.php
index 0a9bf4b59c9..c2b08c72f30 100644
--- a/apps/theming/tests/Settings/PersonalTest.php
+++ b/apps/theming/tests/Settings/PersonalTest.php
@@ -30,6 +30,7 @@ namespace OCA\Theming\Tests\Settings;
use OCA\Theming\AppInfo\Application;
use OCA\Theming\ImageManager;
use OCA\Theming\ITheme;
+use OCA\Theming\Service\BackgroundService;
use OCA\Theming\Service\ThemesService;
use OCA\Theming\Settings\Personal;
use OCA\Theming\Themes\DarkHighContrastTheme;
@@ -116,18 +117,23 @@ class PersonalTest extends TestCase {
->with('enforce_theme', '')
->willReturn($enforcedTheme);
- $this->config->expects($this->once())
+ $this->config->expects($this->any())
->method('getUserValue')
- ->with('admin', 'core', 'apporder')
- ->willReturn('[]');
+ ->willReturnMap([
+ ['admin', 'core', 'apporder', '[]', '[]'],
+ ['admin', 'theming', 'background_image', BackgroundService::BACKGROUND_DEFAULT],
+ ]);
$this->appManager->expects($this->once())
->method('getDefaultAppForUser')
->willReturn('forcedapp');
- $this->initialStateService->expects($this->exactly(4))
+ $this->initialStateService->expects($this->exactly(7))
->method('provideInitialState')
->withConsecutive(
+ ['shippedBackgrounds', BackgroundService::SHIPPED_BACKGROUNDS],
+ ['themingDefaults'],
+ ['userBackgroundImage'],
['themes', $themesState],
['enforceTheme', $enforcedTheme],
['isUserThemingDisabled', false],
diff --git a/apps/theming/tests/ThemingDefaultsTest.php b/apps/theming/tests/ThemingDefaultsTest.php
index 2011b62c3ea..0ea12f82563 100644
--- a/apps/theming/tests/ThemingDefaultsTest.php
+++ b/apps/theming/tests/ThemingDefaultsTest.php
@@ -455,82 +455,38 @@ class ThemingDefaultsTest extends TestCase {
'with fallback default' => [
'disableTheming' => 'no',
'primaryColor' => '',
- 'backgroundColor' => '',
- 'userBackgroundColor' => '',
- 'userPrimaryColor' => '',
- 'expected' => BackgroundService::DEFAULT_COLOR,
- ],
- 'with custom admin background' => [
- 'disableTheming' => 'no',
- 'primaryColor' => '',
- 'backgroundColor' => '#123',
- 'userBackgroundColor' => '',
- 'userPrimaryColor' => '',
- 'expected' => '#123',
- ],
- 'with custom invalid admin background' => [
- 'disableTheming' => 'no',
- 'primaryColor' => '',
- 'backgroundColor' => 'invalid-name',
- 'userBackgroundColor' => '',
'userPrimaryColor' => '',
'expected' => BackgroundService::DEFAULT_COLOR,
],
'with custom admin primary' => [
'disableTheming' => 'no',
'primaryColor' => '#aaa',
- 'backgroundColor' => '',
- 'userBackgroundColor' => '',
'userPrimaryColor' => '',
'expected' => '#aaa',
],
'with custom invalid admin primary' => [
'disableTheming' => 'no',
'primaryColor' => 'invalid',
- 'backgroundColor' => '',
- 'userBackgroundColor' => '',
'userPrimaryColor' => '',
'expected' => BackgroundService::DEFAULT_COLOR,
],
- 'with custom user background' => [
- 'disableTheming' => 'no',
- 'primaryColor' => '',
- 'backgroundColor' => '',
- 'userBackgroundColor' => '#456',
- 'userPrimaryColor' => '#456',
- 'expected' => '#456',
- ],
'with custom invalid user primary' => [
'disableTheming' => 'no',
'primaryColor' => '',
- 'backgroundColor' => '',
- 'userBackgroundColor' => '',
'userPrimaryColor' => 'invalid-name',
'expected' => BackgroundService::DEFAULT_COLOR,
],
'with custom user primary' => [
'disableTheming' => 'no',
'primaryColor' => '',
- 'backgroundColor' => '',
- 'userBackgroundColor' => '',
'userPrimaryColor' => '#bbb',
'expected' => '#bbb',
],
- 'with custom invalid user background' => [
- 'disableTheming' => 'no',
- 'primaryColor' => '',
- 'backgroundColor' => '',
- 'userBackgroundColor' => 'invalid-name',
- 'userPrimaryColor' => '',
- 'expected' => BackgroundService::DEFAULT_COLOR,
- ],
- 'with custom admin and user background' => [
- 'disableTheming' => 'no',
- 'primaryColor' => '',
- 'backgroundColor' => '#123',
- 'userBackgroundColor' => '#456',
- 'userPrimaryColor' => '#456',
- 'expected' => '#456',
+ 'with disabled user theming primary' => [
+ 'disableTheming' => 'yes',
+ 'primaryColor' => '#aaa',
+ 'userPrimaryColor' => '#bbb',
+ 'expected' => '#aaa',
],
];
}
@@ -538,7 +494,7 @@ class ThemingDefaultsTest extends TestCase {
/**
* @dataProvider dataGetColorPrimary
*/
- public function testGetColorPrimary(string $disableTheming, string $primaryColor, string $backgroundColor, string $userBackgroundColor, $userPrimaryColor, $expected) {
+ public function testGetColorPrimary(string $disableTheming, string $primaryColor, string $userPrimaryColor, string $expected) {
$user = $this->createMock(IUser::class);
$this->userSession->expects($this->any())
->method('getUser')
@@ -552,15 +508,12 @@ class ThemingDefaultsTest extends TestCase {
->willReturnMap([
['theming', 'disable-user-theming', 'no', $disableTheming],
['theming', 'primary_color', '', $primaryColor],
- ['theming', 'background_color', '', $backgroundColor],
]);
$this->config
->expects($this->any())
->method('getUserValue')
- ->willReturnMap([
- ['user', 'theming', 'background_color', '', $userBackgroundColor],
- ['user', 'theming', 'primary_color', $userBackgroundColor, $userPrimaryColor],
- ]);
+ ->with('user', 'theming', 'primary_color', '')
+ ->willReturn($userPrimaryColor);
$this->assertEquals($expected, $this->template->getColorPrimary());
}
@@ -668,15 +621,10 @@ class ThemingDefaultsTest extends TestCase {
->method('deleteAppValue')
->with('theming', 'primary_color');
$this->config
- ->expects($this->exactly(2))
+ ->expects($this->once())
->method('getAppValue')
- ->withConsecutive(
- ['theming', 'cachebuster', '0'],
- ['theming', 'primary_color', null],
- )->willReturnOnConsecutiveCalls(
- '15',
- $this->defaults->getColorPrimary(),
- );
+ ->with('theming', 'cachebuster', '0')
+ ->willReturn('15');
$this->config
->expects($this->once())
->method('setAppValue')