diff --git a/framework/cloud/iauthorizationservice.h b/framework/cloud/iauthorizationservice.h index c0b6960c5f..87b1ac7630 100644 --- a/framework/cloud/iauthorizationservice.h +++ b/framework/cloud/iauthorizationservice.h @@ -25,7 +25,6 @@ #include "modularity/imoduleinterface.h" #include "cloudtypes.h" -#include "types/val.h" #include "types/retval.h" namespace muse::cloud { @@ -40,8 +39,6 @@ class IAuthorizationService : MODULE_CONTEXT_INTERFACE virtual void signIn() = 0; virtual void signOut() = 0; - virtual RetVal ensureAuthorization(bool publishingScore, const std::string& text = {}) = 0; - virtual ValCh userAuthorized() const = 0; virtual const AccountInfo& accountInfo() const = 0; diff --git a/framework/cloud/internal/abstractcloudservice.cpp b/framework/cloud/internal/abstractcloudservice.cpp index ff4f9cb951..7fec0d8cff 100644 --- a/framework/cloud/internal/abstractcloudservice.cpp +++ b/framework/cloud/internal/abstractcloudservice.cpp @@ -39,7 +39,6 @@ #include "oauthhttpserverreplyhandler.h" -#include "defer.h" #include "log.h" using namespace muse; @@ -311,19 +310,6 @@ void AbstractCloudService::signOut() }); } -RetVal AbstractCloudService::ensureAuthorization(bool publishingScore, const std::string& text) -{ - if (m_userAuthorized.val) { - return muse::make_ok(); - } - - UriQuery query("muse://cloud/requireauthorization"); - query.addParam("text", Val(text)); - query.addParam("cloudCode", Val(cloudInfo().code)); - query.addParam("publishingScore", Val(publishingScore)); - return interactive()->openSync(query); -} - ValCh AbstractCloudService::userAuthorized() const { return m_userAuthorized; diff --git a/framework/cloud/internal/abstractcloudservice.h b/framework/cloud/internal/abstractcloudservice.h index 0e37d6c9f3..11cf6d1e4f 100644 --- a/framework/cloud/internal/abstractcloudservice.h +++ b/framework/cloud/internal/abstractcloudservice.h @@ -32,7 +32,6 @@ #include "ui/iuiconfiguration.h" #include "io/ifilesystem.h" #include "network/inetworkmanagercreator.h" -#include "interactive/iinteractive.h" #include "interactive/iplatforminteractive.h" #include "multiwindows/imultiwindowsprovider.h" @@ -63,7 +62,6 @@ class AbstractCloudService : public QObject, public IAuthorizationService, publi muse::GlobalInject networkManagerCreator; muse::GlobalInject multiwindowsProvider; muse::GlobalInject platformInteractive; - muse::ContextInject interactive = { this }; public: explicit AbstractCloudService(const modularity::ContextPtr& iocCtx, QObject* parent = nullptr); @@ -74,8 +72,6 @@ class AbstractCloudService : public QObject, public IAuthorizationService, publi void signIn() override; void signOut() override; - RetVal ensureAuthorization(bool publishingScore, const std::string& text = {}) override; - ValCh userAuthorized() const override; const AccountInfo& accountInfo() const override; diff --git a/framework/cloud/tests/mocks/audiocomservicemock.h b/framework/cloud/tests/mocks/audiocomservicemock.h new file mode 100644 index 0000000000..b73ccaa8a7 --- /dev/null +++ b/framework/cloud/tests/mocks/audiocomservicemock.h @@ -0,0 +1,42 @@ +/* + * SPDX-License-Identifier: GPL-3.0-only + * MuseScore-CLA-applies + * + * MuseScore + * Music Composition & Notation + * + * Copyright (C) 2026 MuseScore BVBA and others + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 3 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#pragma once + +#include + +#include "cloud/audiocom/iaudiocomservice.h" + +namespace muse::cloud { +class AudioComServiceMock : public IAudioComService +{ +public: + MOCK_METHOD(IAuthorizationServicePtr, authorization, (), (override)); + MOCK_METHOD(QUrl, projectManagerUrl, (), (const, override)); + + MOCK_METHOD(ProgressPtr, uploadAudio, + (DevicePtr audioData, const QString& audioFormat, const QString& title, const QUrl& existingUrl, Visibility visibility, + bool replaceExisting), (override)); + + MOCK_METHOD(CloudInfo, cloudInfo, (), (const, override)); +}; +} diff --git a/framework/cloud/tests/mocks/authorizationservicemock.h b/framework/cloud/tests/mocks/authorizationservicemock.h new file mode 100644 index 0000000000..30a6ce4082 --- /dev/null +++ b/framework/cloud/tests/mocks/authorizationservicemock.h @@ -0,0 +1,41 @@ +/* + * SPDX-License-Identifier: GPL-3.0-only + * MuseScore-CLA-applies + * + * MuseScore + * Music Composition & Notation + * + * Copyright (C) 2026 MuseScore BVBA and others + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 3 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#pragma once + +#include + +#include "cloud/iauthorizationservice.h" + +namespace muse::cloud { +class AuthorizationServiceMock : public IAuthorizationService +{ +public: + MOCK_METHOD(void, signUp, (), (override)); + MOCK_METHOD(void, signIn, (), (override)); + MOCK_METHOD(void, signOut, (), (override)); + MOCK_METHOD(ValCh, userAuthorized, (), (const, override)); + MOCK_METHOD(const AccountInfo&, accountInfo, (), (const, override)); + MOCK_METHOD(CloudInfo, cloudInfo, (), (const, override)); + MOCK_METHOD(Ret, checkCloudIsAvailable, (), (const, override)); +}; +} diff --git a/framework/cloud/tests/mocks/musescorecomservicemock.h b/framework/cloud/tests/mocks/musescorecomservicemock.h new file mode 100644 index 0000000000..e52b1c3946 --- /dev/null +++ b/framework/cloud/tests/mocks/musescorecomservicemock.h @@ -0,0 +1,46 @@ +/* + * SPDX-License-Identifier: GPL-3.0-only + * MuseScore-CLA-applies + * + * MuseScore + * Music Composition & Notation + * + * Copyright (C) 2026 MuseScore BVBA and others + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 3 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#pragma once + +#include + +#include "cloud/musescorecom/imusescorecomservice.h" + +namespace muse::cloud { +class MuseScoreComServiceMock : public IMuseScoreComService +{ +public: + MOCK_METHOD(IAuthorizationServicePtr, authorization, (), (override)); + MOCK_METHOD(QUrl, scoreManagerUrl, (), (const, override)); + + MOCK_METHOD(ProgressPtr, uploadScore, + (DevicePtr scoreData, const QString& title, cloud::Visibility visibility, const QUrl& sourceUrl, int revisionId), + (override)); + MOCK_METHOD(ProgressPtr, uploadAudio, (DevicePtr audioData, const QString& audioFormat, const QUrl& sourceUrl), (override)); + + MOCK_METHOD(RetVal, downloadScoreInfo, (const QUrl& sourceUrl), (override)); + MOCK_METHOD(RetVal, downloadScoreInfo, (int scoreId), (override)); + MOCK_METHOD(async::Promise, downloadScoresList, (int scoresPerBatch, int batchNumber), (override)); + MOCK_METHOD(ProgressPtr, downloadScore, (int scoreId, DevicePtr scoreData, const QString& hash, const QString& secret), (override)); +}; +} diff --git a/framework/interactive/tests/mocks/platforminteractivemock.h b/framework/interactive/tests/mocks/platforminteractivemock.h new file mode 100644 index 0000000000..6b0ec736d6 --- /dev/null +++ b/framework/interactive/tests/mocks/platforminteractivemock.h @@ -0,0 +1,42 @@ +/* + * SPDX-License-Identifier: GPL-3.0-only + * MuseScore-CLA-applies + * + * MuseScore + * Music Composition & Notation + * + * Copyright (C) 2026 MuseScore BVBA and others + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 3 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#pragma once + +#include + +#include "interactive/iplatforminteractive.h" + +namespace muse { +class PlatformInteractiveMock : public IPlatformInteractive +{ +public: + MOCK_METHOD(Ret, openUrl, (const std::string& url), (const, override)); + MOCK_METHOD(Ret, openUrl, (const QUrl& url), (const, override)); + + MOCK_METHOD(Ret, isAppExists, (const std::string& appIdentifier), (const, override)); + MOCK_METHOD(Ret, canOpenApp, (const UriQuery& uri), (const, override)); + MOCK_METHOD(async::Promise, openApp, (const UriQuery& uri), (const, override)); + + MOCK_METHOD(Ret, revealInFileBrowser, (const io::path_t& filePath), (const, override)); +}; +} diff --git a/framework/stubs/cloud/authorizationservicestub.cpp b/framework/stubs/cloud/authorizationservicestub.cpp index a83e88780b..5c5c65ab32 100644 --- a/framework/stubs/cloud/authorizationservicestub.cpp +++ b/framework/stubs/cloud/authorizationservicestub.cpp @@ -37,11 +37,6 @@ void AuthorizationServiceStub::signOut() { } -RetVal AuthorizationServiceStub::ensureAuthorization(bool, const std::string&) -{ - return muse::make_ret(Ret::Code::NotSupported); -} - ValCh AuthorizationServiceStub::userAuthorized() const { return ValCh(); diff --git a/framework/stubs/cloud/authorizationservicestub.h b/framework/stubs/cloud/authorizationservicestub.h index 50b7cf6a6f..dc7d2c7f15 100644 --- a/framework/stubs/cloud/authorizationservicestub.h +++ b/framework/stubs/cloud/authorizationservicestub.h @@ -32,8 +32,6 @@ class AuthorizationServiceStub : public IAuthorizationService void signIn() override; void signOut() override; - RetVal ensureAuthorization(bool publishingScore, const std::string& text = {}) override; - ValCh userAuthorized() const override; const AccountInfo& accountInfo() const override;