diff --git a/Build_android/configure.sh b/Build_android/configure.sh index ea29c38b29..59b35659ae 100755 --- a/Build_android/configure.sh +++ b/Build_android/configure.sh @@ -25,7 +25,7 @@ DO_OPENSSL=1 DO_CMAKE=1 DO_CPPRESTSDK=1 -BOOSTVER=1.69.0 +BOOSTVER=1.70.0 OPENSSLVER=1.1.0j CMAKEVER=3.14.0 @@ -54,8 +54,8 @@ do DO_OPENSSL=0 ;; "--skip-cmake") - DO_CMAKE=0 - ;; + DO_CMAKE=0 + ;; "--skip-cpprestsdk") DO_CPPRESTSDK=0 ;; @@ -104,10 +104,10 @@ NDK_DIR=`cd "${ANDROID_NDK}" && pwd` SRC_DIR=`pwd` if [ -z "$NCPU" ]; then - NCPU=4 - if uname -s | grep -i "linux" > /dev/null ; then - NCPU=`cat /proc/cpuinfo | grep -c -i processor` - fi + NCPU=4 + if uname -s | grep -i "linux" > /dev/null ; then + NCPU=`cat /proc/cpuinfo | grep -c -i processor` + fi fi # ----------------------- @@ -151,11 +151,12 @@ if [ "${DO_OPENSSL}" == "1" ]; then ( # ----- # Uses the build script from Moritz Wundke (formerly MysticTreeGames) # https://github.com/moritz-wundke/Boost-for-Android +# (plus the patch https://github.com/o01eg/Boost-for-Android/tree/ndk-bump-21) if [ "${DO_BOOST}" == "1" ]; then ( - if [ ! -d 'Boost-for-Android' ]; then git clone https://github.com/moritz-wundke/Boost-for-Android; fi + if [ ! -d 'Boost-for-Android' ]; then git clone https://github.com/o01eg/Boost-for-Android/; fi cd Boost-for-Android - git checkout 245ea53385a55742a9ab08a8bd32c6a2dc0bbea4 + git checkout 7626dd6f7cab7866dce20e685d4a1b11194366a7 PATH="$PATH:$NDK_DIR" \ CXXFLAGS="-std=gnu++11" \ ./build-android.sh \ @@ -186,16 +187,17 @@ if [ "${DO_CMAKE}" == "1" ]; then ( if [ "${DO_CPPRESTSDK}" == "1" ]; then # Use the builtin CMake toolchain configuration that comes with the NDK function build_cpprestsdk { ( - rm -rf $1 + rm -rf $1 ./cmake-${CMAKEVER}/bin/cmake \ -DCMAKE_TOOLCHAIN_FILE="${ANDROID_NDK}/build/cmake/android.toolchain.cmake" \ -DANDROID_NDK="${ANDROID_NDK}" \ -DANDROID_TOOLCHAIN=clang \ -DANDROID_ABI=$2 \ -DBOOST_VERSION="${BOOSTVER}" \ + -DCPPREST_EXCLUDE_WEBSOCKETS=ON \ -DCMAKE_BUILD_TYPE=$3 \ - -S "${DIR}/.." \ - -B $1 + -S "${DIR}/.." \ + -B $1 make -j $NCPU -C $1 ) } diff --git a/Release/tests/functional/http/client/outside_tests.cpp b/Release/tests/functional/http/client/outside_tests.cpp index 05bb306e7a..1b3f64a4ca 100644 --- a/Release/tests/functional/http/client/outside_tests.cpp +++ b/Release/tests/functional/http/client/outside_tests.cpp @@ -290,77 +290,6 @@ SUITE(outside_tests) }); } #endif // !defined(__cplusplus_winrt) - - TEST_FIXTURE(uri_address, outside_ssl_json) - { - // Create URI for: - // https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&playlistId=UUF1hMUVwlrvlVMjUGOZExgg&key=AIzaSyAviHxf_y0SzNoAq3iKqvWVE4KQ0yylsnk - uri_builder playlistUri(U("https://www.googleapis.com/youtube/v3/playlistItems?")); - playlistUri.append_query(U("part"), U("snippet")); - playlistUri.append_query(U("playlistId"), U("UUF1hMUVwlrvlVMjUGOZExgg")); - playlistUri.append_query(U("key"), U("AIzaSyAviHxf_y0SzNoAq3iKqvWVE4KQ0yylsnk")); - - // Send request - web::http::client::http_client playlistClient(playlistUri.to_uri()); - - handle_timeout([&] { - // Retry up to 4 times. - for (int i = 0; i < 4; ++i) - { - try - { - playlistClient.request(methods::GET) - .then([=](http_response playlistResponse) -> pplx::task { - return playlistResponse.extract_json(); - }) - .then([=](json::value v) { - int count = 0; - auto& obj = v.as_object(); - - VERIFY_ARE_NOT_EQUAL(obj.find(U("pageInfo")), obj.end()); - VERIFY_ARE_NOT_EQUAL(obj.find(U("items")), obj.end()); - - auto& items = obj[U("items")]; - - for (auto iter = items.as_array().cbegin(); iter != items.as_array().cend(); ++iter) - { - const auto& item = *iter; - auto iSnippet = item.as_object().find(U("snippet")); - if (iSnippet == item.as_object().end()) - { - throw std::runtime_error("snippet key not found"); - } - auto iTitle = iSnippet->second.as_object().find(U("title")); - if (iTitle == iSnippet->second.as_object().end()) - { - throw std::runtime_error("title key not found"); - } - auto name = iTitle->second.serialize(); - count++; - } - VERIFY_ARE_EQUAL(3, count); // Update this accordingly, if the number of items changes - }) - .wait(); - break; - } - catch (web::http::http_exception const& e) - { -#if defined(_MSC_VER) && !defined(__cplusplus_winrt) - if (e.error_code().value() != API_QUERY_DATA_AVAILABLE || i == 3) - { - // If we didn't get a "connection broken" error (or we are on the last retry), rethrow it - throw; - } -#else - (void)e; - throw; -#endif - os_utilities::sleep(1000); - } - } - }); - } - } // SUITE(outside_tests) } // namespace client diff --git a/Release/tests/functional/json/CMakeLists.txt b/Release/tests/functional/json/CMakeLists.txt index fb10c885f7..25c90f29c1 100644 --- a/Release/tests/functional/json/CMakeLists.txt +++ b/Release/tests/functional/json/CMakeLists.txt @@ -15,5 +15,3 @@ if(UNIX AND NOT APPLE) cpprest_find_boost() target_link_libraries(json_test PRIVATE cpprestsdk_boost_internal) endif() - -configure_pch(json_test stdafx.h stdafx.cpp) diff --git a/Release/tests/functional/json/construction_tests.cpp b/Release/tests/functional/json/construction_tests.cpp index ee5d9cbbce..111b1454e1 100644 --- a/Release/tests/functional/json/construction_tests.cpp +++ b/Release/tests/functional/json/construction_tests.cpp @@ -11,7 +11,8 @@ * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- ****/ -#include "stdafx.h" +#include "cpprest/json.h" +#include "unittestpp.h" using namespace web; using namespace utility; diff --git a/Release/tests/functional/json/fuzz_tests.cpp b/Release/tests/functional/json/fuzz_tests.cpp index a925bf9dfb..80b9a81b04 100644 --- a/Release/tests/functional/json/fuzz_tests.cpp +++ b/Release/tests/functional/json/fuzz_tests.cpp @@ -10,10 +10,10 @@ * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- ****/ -#include "stdafx.h" - +#include "cpprest/json.h" #include "cpprest/containerstream.h" #include "cpprest/filestream.h" +#include "unittestpp.h" using namespace web; diff --git a/Release/tests/functional/json/iterator_tests.cpp b/Release/tests/functional/json/iterator_tests.cpp index e6c8e60ec3..0e72709aa3 100644 --- a/Release/tests/functional/json/iterator_tests.cpp +++ b/Release/tests/functional/json/iterator_tests.cpp @@ -11,8 +11,8 @@ * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- ****/ -#include "stdafx.h" - +#include "cpprest/json.h" +#include "unittestpp.h" #include using namespace web; diff --git a/Release/tests/functional/json/json_numbers_tests.cpp b/Release/tests/functional/json/json_numbers_tests.cpp index 538d44d367..5fa90267ff 100644 --- a/Release/tests/functional/json/json_numbers_tests.cpp +++ b/Release/tests/functional/json/json_numbers_tests.cpp @@ -11,8 +11,8 @@ * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- ****/ -#include "stdafx.h" - +#include "cpprest/json.h" +#include "unittestpp.h" #include #include diff --git a/Release/tests/functional/json/json_tests.h b/Release/tests/functional/json/json_tests.h deleted file mode 100644 index 2d0bac62d1..0000000000 --- a/Release/tests/functional/json/json_tests.h +++ /dev/null @@ -1,25 +0,0 @@ -/*** - * Copyright (C) Microsoft. All rights reserved. - * Licensed under the MIT license. See LICENSE.txt file in the project root for full license information. - * - * =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ - * - * json_tests.h - * - * Common utilities and helper functions for JSON tests. - * - * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- - ****/ - -#include "cpprest/json.h" -#include "unittestpp.h" - -namespace tests -{ -namespace functional -{ -namespace json_tests -{ -} -} // namespace functional -} // namespace tests diff --git a/Release/tests/functional/json/negative_parsing_tests.cpp b/Release/tests/functional/json/negative_parsing_tests.cpp index 33a678ab16..6c2ee9375f 100644 --- a/Release/tests/functional/json/negative_parsing_tests.cpp +++ b/Release/tests/functional/json/negative_parsing_tests.cpp @@ -10,7 +10,8 @@ * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- ****/ -#include "stdafx.h" +#include "cpprest/json.h" +#include "unittestpp.h" using namespace web; using namespace utility; diff --git a/Release/tests/functional/json/parsing_tests.cpp b/Release/tests/functional/json/parsing_tests.cpp index cf5a261bf0..2a4db09538 100644 --- a/Release/tests/functional/json/parsing_tests.cpp +++ b/Release/tests/functional/json/parsing_tests.cpp @@ -9,8 +9,8 @@ * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- ****/ -#include "stdafx.h" - +#include "cpprest/json.h" +#include "unittestpp.h" #include #include @@ -26,6 +26,144 @@ using namespace web; using namespace utility; using namespace utility::conversions; +static utility::string_t youtubeJson = _XPLATSTR( +R"delimeter({ + "kind": "youtube#playlistItemListResponse", + "etag": "\"Fznwjl6JEQdo1MGvHOGaz_YanRU/ranGcWzseanYs9xZ0NXAq24qK-w\"", + "pageInfo": { + "totalResults": 3, + "resultsPerPage": 5 + }, + "items": [ + { + "kind": "youtube#playlistItem", + "etag": "\"Fznwjl6JEQdo1MGvHOGaz_YanRU/phfRXORDKFrYjeJGWbI8MbIk08A\"", + "id": "VVVGMWhNVVZ3bHJ2bFZNalVHT1pFeGdnLm12RERIeEJyd1U4", + "snippet": { + "publishedAt": "2013-05-24T22:03:10.000Z", + "channelId": "UCF1hMUVwlrvlVMjUGOZExgg", + "title": "C++ REST SDK (\"Casablanca\")", + "description": "This library is a Microsoft effort to support cloud-based client-server communication in native code using a modern asynchronous C++ API design.", + "thumbnails": { + "default": { + "url": "https://i.ytimg.com/vi/mvDDHxBrwU8/default.jpg", + "width": 120, + "height": 90 + }, + "medium": { + "url": "https://i.ytimg.com/vi/mvDDHxBrwU8/mqdefault.jpg", + "width": 320, + "height": 180 + }, + "high": { + "url": "https://i.ytimg.com/vi/mvDDHxBrwU8/hqdefault.jpg", + "width": 480, + "height": 360 + }, + "standard": { + "url": "https://i.ytimg.com/vi/mvDDHxBrwU8/sddefault.jpg", + "width": 640, + "height": 480 + }, + "maxres": { + "url": "https://i.ytimg.com/vi/mvDDHxBrwU8/maxresdefault.jpg", + "width": 1280, + "height": 720 + } + }, + "channelTitle": "casablancacore", + "playlistId": "UUF1hMUVwlrvlVMjUGOZExgg", + "position": 0, + "resourceId": { + "kind": "youtube#video", + "videoId": "mvDDHxBrwU8" + } + } + }, + { + "kind": "youtube#playlistItem", + "etag": "\"Fznwjl6JEQdo1MGvHOGaz_YanRU/J65jYO0AIlbIqd4JpVigajlhVnE\"", + "id": "VVVGMWhNVVZ3bHJ2bFZNalVHT1pFeGdnLmlFVU9fdDhFYW5r", + "snippet": { + "publishedAt": "2013-05-07T18:47:24.000Z", + "channelId": "UCF1hMUVwlrvlVMjUGOZExgg", + "title": "C++ REST SDK", + "description": "A brief introduction to the C++ REST SDK. This video goes over high level concepts and features of the library. \n\nFor more information visit: http://casablanca.codeplex.com\nFor more information on PPL tasks visit: http://msdn.microsoft.com/en-us/library/dd492418.aspx", + "thumbnails": { + "default": { + "url": "https://i.ytimg.com/vi/iEUO_t8Eank/default.jpg", + "width": 120, + "height": 90 + }, + "medium": { + "url": "https://i.ytimg.com/vi/iEUO_t8Eank/mqdefault.jpg", + "width": 320, + "height": 180 + }, + "high": { + "url": "https://i.ytimg.com/vi/iEUO_t8Eank/hqdefault.jpg", + "width": 480, + "height": 360 + }, + "standard": { + "url": "https://i.ytimg.com/vi/iEUO_t8Eank/sddefault.jpg", + "width": 640, + "height": 480 + } + }, + "channelTitle": "casablancacore", + "playlistId": "UUF1hMUVwlrvlVMjUGOZExgg", + "position": 1, + "resourceId": { + "kind": "youtube#video", + "videoId": "iEUO_t8Eank" + } + } + }, + { + "kind": "youtube#playlistItem", + "etag": "\"Fznwjl6JEQdo1MGvHOGaz_YanRU/XMpuK2N4-LOhDWtgCG8nBw7eNl8\"", + "id": "VVVGMWhNVVZ3bHJ2bFZNalVHT1pFeGdnLk41cnlJN3U5RVFB", + "snippet": { + "publishedAt": "2013-05-02T21:24:56.000Z", + "channelId": "UCF1hMUVwlrvlVMjUGOZExgg", + "title": "bunny", + "description": "", + "thumbnails": { + "default": { + "url": "https://i.ytimg.com/vi/N5ryI7u9EQA/default.jpg", + "width": 120, + "height": 90 + }, + "medium": { + "url": "https://i.ytimg.com/vi/N5ryI7u9EQA/mqdefault.jpg", + "width": 320, + "height": 180 + }, + "high": { + "url": "https://i.ytimg.com/vi/N5ryI7u9EQA/hqdefault.jpg", + "width": 480, + "height": 360 + }, + "standard": { + "url": "https://i.ytimg.com/vi/N5ryI7u9EQA/sddefault.jpg", + "width": 640, + "height": 480 + } + }, + "channelTitle": "casablancacore", + "playlistId": "UUF1hMUVwlrvlVMjUGOZExgg", + "position": 2, + "resourceId": { + "kind": "youtube#video", + "videoId": "N5ryI7u9EQA" + } + } + } + ] +})delimeter" +); + namespace tests { namespace functional @@ -762,6 +900,36 @@ SUITE(parsing_tests) #endif } + TEST(youtube_api) + { + auto v = json::value::parse(youtubeJson); + int count = 0; + auto& obj = v.as_object(); + + VERIFY_ARE_NOT_EQUAL(obj.find(U("pageInfo")), obj.end()); + VERIFY_ARE_NOT_EQUAL(obj.find(U("items")), obj.end()); + + auto& items = obj[U("items")]; + + for (auto iter = items.as_array().cbegin(); iter != items.as_array().cend(); ++iter) + { + const auto& item = *iter; + auto iSnippet = item.as_object().find(U("snippet")); + if (iSnippet == item.as_object().end()) + { + throw std::runtime_error("snippet key not found"); + } + auto iTitle = iSnippet->second.as_object().find(U("title")); + if (iTitle == iSnippet->second.as_object().end()) + { + throw std::runtime_error("title key not found"); + } + auto name = iTitle->second.serialize(); + count++; + } + VERIFY_ARE_EQUAL(3, count); // Update this accordingly, if the number of items changes + } + } // SUITE(parsing_tests) } // namespace json_tests diff --git a/Release/tests/functional/json/stdafx.cpp b/Release/tests/functional/json/stdafx.cpp deleted file mode 100644 index 48b9655134..0000000000 --- a/Release/tests/functional/json/stdafx.cpp +++ /dev/null @@ -1,14 +0,0 @@ -/*** - * Copyright (C) Microsoft. All rights reserved. - * Licensed under the MIT license. See LICENSE.txt file in the project root for full license information. - * - * =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ - **/ -// stdafx.cpp : -// Include the standard header and generate the precompiled header. - -#include "stdafx.h" - -#if WIN32 -__declspec(dllexport) int json_test_generate_lib = 0; -#endif diff --git a/Release/tests/functional/json/stdafx.h b/Release/tests/functional/json/stdafx.h deleted file mode 100644 index bb43264b61..0000000000 --- a/Release/tests/functional/json/stdafx.h +++ /dev/null @@ -1,19 +0,0 @@ -/*** - * Copyright (C) Microsoft. All rights reserved. - * Licensed under the MIT license. See LICENSE.txt file in the project root for full license information. - * - * =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ - * - * stdafx.h - * - * Pre-compiled headers - * - * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- - ****/ - -#pragma once - -#include "unittestpp.h" -#include - -#include "json_tests.h" diff --git a/Release/tests/functional/json/to_as_and_operators_tests.cpp b/Release/tests/functional/json/to_as_and_operators_tests.cpp index 6103adf6a4..cbf2a92e04 100644 --- a/Release/tests/functional/json/to_as_and_operators_tests.cpp +++ b/Release/tests/functional/json/to_as_and_operators_tests.cpp @@ -9,7 +9,8 @@ * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- ****/ -#include "stdafx.h" +#include "cpprest/json.h" +#include "unittestpp.h" using namespace web; using namespace utility; diff --git a/azure-devops/build-windows.yml b/azure-devops/build-windows.yml index 45ea392a82..2a5de3c509 100644 --- a/azure-devops/build-windows.yml +++ b/azure-devops/build-windows.yml @@ -11,6 +11,8 @@ jobs: vcpkgLocation: '$(Build.SourcesDirectory)/vcpkg' vcpkgResponseFile: $(Build.SourcesDirectory)/azure-devops/vcpkg-windows.txt steps: + - script: git submodule update --init vcpkg + displayName: Checkout vcpkg submodule - task: CacheBeta@0 displayName: Cache vcpkg inputs: diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 55f7683b3a..9a03666ec8 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -21,20 +21,23 @@ jobs: name: 'Windows_VS2017_x64' targetPlatform: x64 image: 'vs2017-win2016' - - template: azure-devops/build-windows.yml - parameters: - name: 'Windows_VS2015_x86' - targetPlatform: x86 - image: 'vs2015-win2012r2' - - template: azure-devops/build-windows.yml - parameters: - name: 'Windows_VS2015_x64' - targetPlatform: x64 - image: 'vs2015-win2012r2' + # VS2015 is disabled for now pending https://github.com/microsoft/vcpkg/pull/10126 + # - template: azure-devops/build-windows.yml + # parameters: + # name: 'Windows_VS2015_x86' + # targetPlatform: x86 + # image: 'vs2015-win2012r2' + # - template: azure-devops/build-windows.yml + # parameters: + # name: 'Windows_VS2015_x64' + # targetPlatform: x64 + # image: 'vs2015-win2012r2' - job: Windows_VS2019_UWP pool: vmImage: 'windows-latest' steps: + - script: git submodule update --init vcpkg + displayName: Checkout vcpkg submodule - script: .\vcpkg\bootstrap-vcpkg.bat displayName: Bootstrap vcpkg - script: .\vcpkg\vcpkg.exe install zlib --triplet x64-uwp --vcpkg-root .\vcpkg @@ -83,6 +86,7 @@ jobs: sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y sudo apt -y update sudo apt install g++-9 ninja-build -y + git submodule update --init vcpkg ./vcpkg/bootstrap-vcpkg.sh ./vcpkg/vcpkg install zlib openssl boost-system boost-date-time boost-regex websocketpp boost-thread boost-filesystem boost-random boost-chrono boost-interprocess brotli --vcpkg-root ./vcpkg displayName: Vcpkg install dependencies diff --git a/vcpkg b/vcpkg index 43fa3e60cf..1be75a28bf 160000 --- a/vcpkg +++ b/vcpkg @@ -1 +1 @@ -Subproject commit 43fa3e60cfb96fa42940d234b011514c8be92256 +Subproject commit 1be75a28bfce2084bb0b59ec92a6853f13d7be66