diff --git a/src/slic3r/Utils/MacDarkMode.mm b/src/slic3r/Utils/MacDarkMode.mm index 17f6f81287..8181abd41f 100644 --- a/src/slic3r/Utils/MacDarkMode.mm +++ b/src/slic3r/Utils/MacDarkMode.mm @@ -39,6 +39,7 @@ using Slic3r::GUI::unique_plugin_download_path; - (void)removeDownloadDelegate:(id)delegate; @end +API_AVAILABLE(macos(11.3)) @interface OrcaWKDownloadDelegate : NSObject { OrcaWKDownloadContext* m_context; @@ -169,10 +170,14 @@ static void wk_decide_navigation_response(WKWebView* webView, should_download = should_download || [disposition rangeOfString:@"attachment" options:NSCaseInsensitiveSearch].location != NSNotFound; } - decisionHandler(should_download ? WKNavigationResponsePolicyDownload : WKNavigationResponsePolicyAllow); + if (@available(macOS 11.3, *)) { + decisionHandler(should_download ? WKNavigationResponsePolicyDownload : WKNavigationResponsePolicyAllow); + } else { + decisionHandler(WKNavigationResponsePolicyAllow); + } } -static void wk_did_become_download(WKWebView* webView, WKNavigationResponse*, WKDownload* download) +static void wk_did_become_download(WKWebView* webView, WKNavigationResponse*, WKDownload* download) API_AVAILABLE(macos(11.3)) { OrcaWKDownloadContext* context = wk_download_context(webView); if (!context) @@ -197,7 +202,7 @@ static void wk_did_become_download_imp(id, SEL, WKWebView* webView, WKNavigationResponse* response, - WKDownload* download) + WKDownload* download) API_AVAILABLE(macos(11.3)) { wk_did_become_download(webView, response, download); } @@ -206,7 +211,7 @@ static void wk_did_become_action_download_imp(id, SEL, WKWebView* webView, WKNavigationAction* action, - WKDownload* download) + WKDownload* download) API_AVAILABLE(macos(11.3)) { (void)action; OrcaWKDownloadContext* context = wk_download_context(webView); @@ -229,14 +234,16 @@ static void install_wk_download_delegate_methods(WKWebView* webView) @selector(webView:decidePolicyForNavigationResponse:decisionHandler:), (IMP)wk_decide_navigation_response_imp, "v@:@@@"); - class_addMethod(delegateClass, - @selector(webView:navigationResponse:didBecomeDownload:), - (IMP)wk_did_become_download_imp, - "v@:@@@"); - class_addMethod(delegateClass, - @selector(webView:navigationAction:didBecomeDownload:), - (IMP)wk_did_become_action_download_imp, - "v@:@@@"); + if (@available(macOS 11.3, *)) { + class_addMethod(delegateClass, + @selector(webView:navigationResponse:didBecomeDownload:), + (IMP)wk_did_become_download_imp, + "v@:@@@"); + class_addMethod(delegateClass, + @selector(webView:navigationAction:didBecomeDownload:), + (IMP)wk_did_become_action_download_imp, + "v@:@@@"); + } } @implementation MacDarkMode diff --git a/tests/slic3rutils/test_plugin_cloud_metadata.cpp b/tests/slic3rutils/test_plugin_cloud_metadata.cpp index c34b596ee0..1232c90e60 100644 --- a/tests/slic3rutils/test_plugin_cloud_metadata.cpp +++ b/tests/slic3rutils/test_plugin_cloud_metadata.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include "plugin_test_utils.hpp" @@ -180,7 +181,18 @@ TEST_CASE("cloud metadata refresh preserves a plugin's stored config", "[PluginC CHECK_FALSE(orphaned.has_error()); CHECK(orphaned.get_update_status() == PluginUpdateStatus::Normal); - // Orphaned is informational only: the local package must remain loadable and usable. + // Orphaned is informational only: the local package must remain loadable and usable. Loading + // it exercises get_storage_dir(), which for a cloud plugin needs a real logged-in session + // (PluginManager::get_storage_dir() throws otherwise) -- the same session a real user would + // already hold for a plugin they'd previously subscribed to and downloaded. Give the manager + // one via the real agent: OrcaCloudServiceAgent's constructor does no networking, and + // set_user_session(..., persist=false) only sets in-memory session state, so this stays a + // fast, offline unit test. + auto cloud_agent = std::make_shared(get_orca_plugins_dir()); + cloud_agent->set_user_session(/*token=*/"test-token", /*user_id=*/"test-user", /*username=*/"test-user", + /*nickname=*/"", /*avatar=*/"", /*refresh_token=*/"", /*persist=*/false); + manager.set_cloud_agent(cloud_agent); + std::string load_error; manager.load_plugin(uuid, /*skip_deps=*/true); REQUIRE(manager.wait_for_plugin_load(uuid, std::chrono::seconds(120), load_error));