blob: 7293843e066ae4da13f6d1c688e769c5a9ac00b5 [file] [log] [blame]
Adam Lesinski16c4d152014-01-24 13:27:13 -08001/*
2 * Copyright (C) 2011 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Narayan Kamath560566d2013-12-03 13:16:03 +000017#define LOG_TAG "ZipUtils_test"
Adam Lesinski16c4d152014-01-24 13:27:13 -080018#include <utils/Log.h>
Narayan Kamath560566d2013-12-03 13:16:03 +000019#include <androidfw/ZipUtils.h>
Adam Lesinski16c4d152014-01-24 13:27:13 -080020
21#include <gtest/gtest.h>
22
23#include <fcntl.h>
24#include <string.h>
25
26namespace android {
27
Narayan Kamath560566d2013-12-03 13:16:03 +000028class ZipUtilsTest : public testing::Test {
Adam Lesinski16c4d152014-01-24 13:27:13 -080029protected:
30 virtual void SetUp() {
31 }
32
33 virtual void TearDown() {
34 }
35};
36
Narayan Kamath560566d2013-12-03 13:16:03 +000037TEST_F(ZipUtilsTest, ZipTimeConvertSuccess) {
Adam Lesinski16c4d152014-01-24 13:27:13 -080038 struct tm t;
39
40 // 2011-06-29 14:40:40
41 long when = 0x3EDD7514;
42
Narayan Kamath560566d2013-12-03 13:16:03 +000043 ZipUtils::zipTimeToTimespec(when, &t);
Adam Lesinski16c4d152014-01-24 13:27:13 -080044
45 EXPECT_EQ(2011, t.tm_year + 1900)
46 << "Year was improperly converted.";
47
Shammi Khattar1ead4742016-04-06 15:33:03 -070048 EXPECT_EQ(5, t.tm_mon)
Adam Lesinski16c4d152014-01-24 13:27:13 -080049 << "Month was improperly converted.";
50
51 EXPECT_EQ(29, t.tm_mday)
52 << "Day was improperly converted.";
53
54 EXPECT_EQ(14, t.tm_hour)
55 << "Hour was improperly converted.";
56
57 EXPECT_EQ(40, t.tm_min)
58 << "Minute was improperly converted.";
59
60 EXPECT_EQ(40, t.tm_sec)
61 << "Second was improperly converted.";
Shammi Khattar1ead4742016-04-06 15:33:03 -070062
63 // We don't have enough information to determine timezone related info.
64 EXPECT_EQ(-1, t.tm_isdst);
65 EXPECT_EQ(0, t.tm_gmtoff);
66 EXPECT_EQ(nullptr, t.tm_zone);
Adam Lesinski16c4d152014-01-24 13:27:13 -080067}
68
69}