OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <gtest/gtest.h> | 5 #include <gtest/gtest.h> |
6 | 6 |
7 #include "chrome/browser/extensions/extension_idle_api.h" | 7 #include "chrome/browser/extensions/api/idle/idle_api.h" |
| 8 |
| 9 using extensions::ExtensionIdleCache; |
8 | 10 |
9 TEST(ExtensionIdleApiTest, CacheTest) { | 11 TEST(ExtensionIdleApiTest, CacheTest) { |
10 double throttle_interval = ExtensionIdleCache::get_throttle_interval(); | 12 double throttle_interval = ExtensionIdleCache::get_throttle_interval(); |
11 int min_threshold = ExtensionIdleCache::get_min_threshold(); | 13 int min_threshold = ExtensionIdleCache::get_min_threshold(); |
12 double now = 10 * min_threshold; | 14 double now = 10 * min_threshold; |
13 | 15 |
14 EXPECT_EQ(IDLE_STATE_UNKNOWN, | 16 EXPECT_EQ(IDLE_STATE_UNKNOWN, |
15 ExtensionIdleCache::CalculateState(min_threshold, now)); | 17 ExtensionIdleCache::CalculateState(min_threshold, now)); |
16 | 18 |
17 ExtensionIdleCache::Update(2 * min_threshold, IDLE_STATE_IDLE, now); | 19 ExtensionIdleCache::Update(2 * min_threshold, IDLE_STATE_IDLE, now); |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 ExtensionIdleCache::Update(2 * min_threshold, IDLE_STATE_LOCKED, now); | 114 ExtensionIdleCache::Update(2 * min_threshold, IDLE_STATE_LOCKED, now); |
113 | 115 |
114 now += 0.2 * throttle_interval; | 116 now += 0.2 * throttle_interval; |
115 ExtensionIdleCache::Update(4 * min_threshold, IDLE_STATE_ACTIVE, now); | 117 ExtensionIdleCache::Update(4 * min_threshold, IDLE_STATE_ACTIVE, now); |
116 | 118 |
117 // Last reported state was ACTIVE. | 119 // Last reported state was ACTIVE. |
118 EXPECT_EQ(IDLE_STATE_ACTIVE, | 120 EXPECT_EQ(IDLE_STATE_ACTIVE, |
119 ExtensionIdleCache::CalculateState(6 * min_threshold, | 121 ExtensionIdleCache::CalculateState(6 * min_threshold, |
120 now + 0.3 * throttle_interval)); | 122 now + 0.3 * throttle_interval)); |
121 } | 123 } |
OLD | NEW |