11e934351Sopenharmony_ci/* 21e934351Sopenharmony_ci * Copyright (c) 2023 Huawei Device Co., Ltd. 31e934351Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 41e934351Sopenharmony_ci * you may not use this file except in compliance with the License. 51e934351Sopenharmony_ci * You may obtain a copy of the License at 61e934351Sopenharmony_ci * 71e934351Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 81e934351Sopenharmony_ci * 91e934351Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 101e934351Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 111e934351Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 121e934351Sopenharmony_ci * See the License for the specific language governing permissions and 131e934351Sopenharmony_ci * limitations under the License. 141e934351Sopenharmony_ci */ 151e934351Sopenharmony_ci 161e934351Sopenharmony_ci#include <iostream> 171e934351Sopenharmony_ci#include <cstring> 181e934351Sopenharmony_ci#include "gtest/gtest.h" 191e934351Sopenharmony_ci#include "http_client_constant.h" 201e934351Sopenharmony_ci#include "netstack_log.h" 211e934351Sopenharmony_ci 221e934351Sopenharmony_ci#define private public 231e934351Sopenharmony_ci#include "http_client.h" 241e934351Sopenharmony_ci#include "http_client_task.h" 251e934351Sopenharmony_ci#include <curl/curl.h> 261e934351Sopenharmony_ci 271e934351Sopenharmony_ciusing namespace OHOS::NetStack::HttpClient; 281e934351Sopenharmony_ci 291e934351Sopenharmony_ciclass HttpClientTest : public testing::Test { 301e934351Sopenharmony_cipublic: 311e934351Sopenharmony_ci static void SetUpTestCase() {} 321e934351Sopenharmony_ci 331e934351Sopenharmony_ci static void TearDownTestCase() {} 341e934351Sopenharmony_ci 351e934351Sopenharmony_ci virtual void SetUp() {} 361e934351Sopenharmony_ci 371e934351Sopenharmony_ci virtual void TearDown() {} 381e934351Sopenharmony_ci}; 391e934351Sopenharmony_ci 401e934351Sopenharmony_cinamespace { 411e934351Sopenharmony_ciusing namespace std; 421e934351Sopenharmony_ciusing namespace testing::ext; 431e934351Sopenharmony_ci 441e934351Sopenharmony_ciHWTEST_F(HttpClientTest, AddRequestInfoTest001, TestSize.Level1) 451e934351Sopenharmony_ci{ 461e934351Sopenharmony_ci HttpClientRequest httpReq; 471e934351Sopenharmony_ci std::string url = "http://www.baidu.com"; 481e934351Sopenharmony_ci httpReq.SetURL(url); 491e934351Sopenharmony_ci 501e934351Sopenharmony_ci HttpSession &session = HttpSession::GetInstance(); 511e934351Sopenharmony_ci auto task = session.CreateTask(httpReq); 521e934351Sopenharmony_ci task->Start(); 531e934351Sopenharmony_ci 541e934351Sopenharmony_ci while (task->GetStatus() != TaskStatus::IDLE) { 551e934351Sopenharmony_ci std::this_thread::sleep_for(std::chrono::milliseconds(100)); 561e934351Sopenharmony_ci } 571e934351Sopenharmony_ci EXPECT_EQ(task->GetStatus(), IDLE); 581e934351Sopenharmony_ci} 591e934351Sopenharmony_ci 601e934351Sopenharmony_ci} // namespace