| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ios/chrome/browser/install_time_util.h" | 5 #include "ios/chrome/browser/install_time_util.h" |
| 6 #include "testing/gtest/include/gtest/gtest.h" | 6 #include "testing/gtest/include/gtest/gtest.h" |
| 7 #include "testing/gtest_mac.h" | 7 #include "testing/gtest_mac.h" |
| 8 | 8 |
| 9 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 10 #error "This file requires ARC support." |
| 11 #endif |
| 12 |
| 9 TEST(InstallTimeUtilTest, ComputeInstallationTime) { | 13 TEST(InstallTimeUtilTest, ComputeInstallationTime) { |
| 10 const base::Time null_time = base::Time(); | 14 const base::Time null_time = base::Time(); |
| 11 const base::Time now = base::Time::Now(); | 15 const base::Time now = base::Time::Now(); |
| 12 const base::Time one_month_ago = now - base::TimeDelta::FromDays(30); | 16 const base::Time one_month_ago = now - base::TimeDelta::FromDays(30); |
| 13 const base::Time sentinel = | 17 const base::Time sentinel = |
| 14 base::Time::FromTimeT(install_time_util::kUnknownInstallDate); | 18 base::Time::FromTimeT(install_time_util::kUnknownInstallDate); |
| 15 | 19 |
| 16 base::Time install_time; | 20 base::Time install_time; |
| 17 base::TimeDelta delta_from_now; | 21 base::TimeDelta delta_from_now; |
| 18 | 22 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 38 EXPECT_FALSE(install_time.is_null()); | 42 EXPECT_FALSE(install_time.is_null()); |
| 39 EXPECT_EQ(sentinel, install_time); | 43 EXPECT_EQ(sentinel, install_time); |
| 40 | 44 |
| 41 // Case 4: Not first run, and NSUserDefaults had an install time. Should | 45 // Case 4: Not first run, and NSUserDefaults had an install time. Should |
| 42 // migrate that to LocalState. | 46 // migrate that to LocalState. |
| 43 install_time = | 47 install_time = |
| 44 install_time_util::ComputeInstallationTimeInternal(false, one_month_ago); | 48 install_time_util::ComputeInstallationTimeInternal(false, one_month_ago); |
| 45 EXPECT_FALSE(install_time.is_null()); | 49 EXPECT_FALSE(install_time.is_null()); |
| 46 EXPECT_EQ(one_month_ago, install_time); | 50 EXPECT_EQ(one_month_ago, install_time); |
| 47 } | 51 } |
| OLD | NEW |