diff options
-rw-r--r-- | c/test.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
@@ -1,3 +1,6 @@ +#include <windows.h> +#include <wininet.h> + #include "data.h" #include "episodelistview.h" #include "pl.h" @@ -219,6 +222,32 @@ TESTS extern CfgA& g_cfg; g_cfg.cEp = i; } + + TEST(Internet) + { + HINTERNET hi, hiUrl; + unsigned char buf[2048]; + DWORD cbRead; + + hi = InternetOpen(L"Episode Browser", + INTERNET_OPEN_TYPE_DIRECT, nullptr, nullptr, + /*INTERNET_FLAG_ASYNC*/0); + if (!hi) + goto a; + + hiUrl = InternetOpenUrl(hi, L"https://www.detectiveconanworld.com/wiki/Anime", + nullptr, 0, INTERNET_FLAG_NO_UI, 0); + if (!hiUrl) + goto b; + + if (!InternetReadFile(hiUrl, &buf, sizeof(buf), &cbRead)) + goto c; + + return; + c: InternetCloseHandle(hiUrl); + b: InternetCloseHandle(hi); + a: FAIL(Win32Error{}.what()); + } }; int RunTests() @@ -233,6 +262,7 @@ int RunTests() //MigrateCfg{} //MigrateDlvDataFromPrologToDisk{}, //DownloadData{}, + Internet{}, }; printf("Results (%llu tests):\n", sizeof(tests)/sizeof(*tests)); |