1/*
2 * Copyright (c) 2021 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16#include <fcntl.h>
17#include <gmock/gmock.h>
18#include <gtest/gtest.h>
19#include <iostream>
20#include <string>
21#include "applypatch/transfer_manager.h"
22#include "log/log.h"
23
24using namespace testing::ext;
25using namespace Updater;
26using namespace std;
27namespace UpdaterUt {
28class TransferManagerUnitTest : public testing::Test {
29public:
30    static void SetUpTestCase(void);
31    static void TearDownTestCase(void) {};
32    void SetUp();
33    void TearDown();
34};
35
36void TransferManagerUnitTest::SetUpTestCase()
37{
38    cout << "Updater Unit TransferManagerUnitTest Setup!" << endl;
39}
40
41void TransferManagerUnitTest::SetUp()
42{
43    cout << "Updater Unit TransferManagerUnitTest Begin!" << endl;
44}
45
46void TransferManagerUnitTest::TearDown()
47{
48    cout << "Updater Unit TransferManagerUnitTest End!" << endl;
49}
50
51HWTEST_F(TransferManagerUnitTest, transfer_manager_test_001, TestSize.Level1)
52{
53    std::unique_ptr<TransferManager> tm = std::make_unique<TransferManager>();
54    std::string cmd = "zero 2,0,1";
55    bool reset = tm->CheckResult(CommandResult::NEED_RETRY, cmd, CommandType::ZERO);
56    EXPECT_EQ(reset, false);
57}
58
59HWTEST_F(TransferManagerUnitTest, transfer_manager_test_002, TestSize.Level1)
60{
61    std::unique_ptr<TransferManager> tm = std::make_unique<TransferManager>();
62    string cmd = tm->ReloadForRetry();
63    EXPECT_STREQ(cmd.c_str(), "");
64}
65} // updater_ut
66