[M120 Migration][VD] Enable direct rendering for TVPlus
[platform/framework/web/chromium-efl.git] / crypto / nss_util_unittest.cc
1 // Copyright 2011 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "crypto/nss_util.h"
6
7 #include <prtime.h>
8
9 #include "base/time/time.h"
10 #include "testing/gtest/include/gtest/gtest.h"
11
12 namespace crypto {
13
14 TEST(NSSUtilTest, PRTimeConversion) {
15   EXPECT_EQ(base::Time::UnixEpoch(), PRTimeToBaseTime(0));
16   EXPECT_EQ(0, BaseTimeToPRTime(base::Time::UnixEpoch()));
17
18   static constexpr PRExplodedTime kPrxtime = {
19       .tm_usec = 342000,
20       .tm_sec = 19,
21       .tm_min = 52,
22       .tm_hour = 2,
23       .tm_mday = 10,
24       .tm_month = 11,  // 0-based
25       .tm_year = 2011,
26       .tm_params = {.tp_gmt_offset = 0, .tp_dst_offset = 0}};
27   PRTime pr_time = PR_ImplodeTime(&kPrxtime);
28
29   static constexpr base::Time::Exploded kExploded = {.year = 2011,
30                                                      .month = 12,  // 1-based
31                                                      .day_of_month = 10,
32                                                      .hour = 2,
33                                                      .minute = 52,
34                                                      .second = 19,
35                                                      .millisecond = 342};
36   base::Time base_time;
37   EXPECT_TRUE(base::Time::FromUTCExploded(kExploded, &base_time));
38
39   EXPECT_EQ(base_time, PRTimeToBaseTime(pr_time));
40   EXPECT_EQ(pr_time, BaseTimeToPRTime(base_time));
41 }
42
43 }  // namespace crypto