| 3023 | choc::ui::WebView::Options opts; |
| 3024 | opts.enableDebugMode = true; |
| 3025 | |
| 3026 | opts.fetchResource = [&] (const std::string& path) -> choc::ui::WebView::Options::Resource |
| 3027 | { |
| 3028 | if (path == "/") |
| 3029 | { |
| 3030 | return { R"(<!DOCTYPE html> <html> |
| 3031 | <script> |
| 3032 | fetch (new Request("./hello.txt")) |
| 3033 | .then (response => response.text()) |
| 3034 | .then (text => succeeded (text)); |
| 3035 | </script> |
| 3036 | </html>)", |
| 3037 | "text/html" }; |
| 3038 | } |
| 3039 | |
| 3040 | return { path, "text/plain" }; |
| 3041 | }; |
| 3042 | |
| 3043 | std::unique_ptr<choc::ui::WebView> webview; |
| 3044 | std::string result; |
| 3045 | |
| 3046 | runTestOnMessageThread ([&] (const std::function<void()>& finished) |
| 3047 | { |
| 3048 | opts.webviewIsReady = [&] (choc::ui::WebView& w) |
| 3049 | { |
| 3050 | if (! w.loadedOK()) |
| 3051 | { |
| 3052 | std::cout << "WebView was unavailable" << std::endl; |
| 3053 | finished(); |
| 3054 | return; |
| 3055 | } |
| 3056 | |
| 3057 | w.bind ("succeeded", [&] (const choc::value::ValueView& args) |
| 3058 | { |
| 3059 | result = choc::json::toString (args); |
| 3060 | finished(); |
| 3061 | return choc::value::Value(); |
| 3062 | }); |
| 3063 | }; |
| 3064 | |
| 3065 | webview = std::make_unique<choc::ui::WebView> (opts); |
| 3066 | }, |
| 3067 | [&] { webview.reset(); }); |
| 3068 | |
| 3069 | CHOC_EXPECT_TRUE (choc::text::contains (result, "hello.txt")); |
| 3070 | } |
| 3071 | } |
| 3072 | |
| 3073 | //============================================================================== |
| 3074 | inline void testCOM (choc::test::TestProgress& progress) |
| 3075 | { |
| 3076 | CHOC_CATEGORY (COM); |
| 3077 | |
| 3078 | { |
| 3079 | CHOC_TEST (RefCounting) |
| 3080 | |
| 3081 | static int numObjs = 0; |
| 3082 |
nothing calls this directly
no test coverage detected