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
24 using namespace testing::ext;
25 using namespace Updater;
26 using namespace std;
27 namespace UpdaterUt {
28 class TransferManagerUnitTest : public testing::Test {
29 public:
30 static void SetUpTestCase(void);
TearDownTestCase(void)31 static void TearDownTestCase(void) {};
32 void SetUp();
33 void TearDown();
34 };
35
SetUpTestCase()36 void TransferManagerUnitTest::SetUpTestCase()
37 {
38 cout << "Updater Unit TransferManagerUnitTest Setup!" << endl;
39 }
40
SetUp()41 void TransferManagerUnitTest::SetUp()
42 {
43 cout << "Updater Unit TransferManagerUnitTest Begin!" << endl;
44 }
45
TearDown()46 void TransferManagerUnitTest::TearDown()
47 {
48 cout << "Updater Unit TransferManagerUnitTest End!" << endl;
49 }
50
51 HWTEST_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
59 HWTEST_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