| 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 | 8 |
| 9 TEST(ExtensionIdleApiTest, CacheTest) { | 9 TEST(ExtensionIdleApiTest, CacheTest) { |
| 10 double throttle_interval = ExtensionIdleCache::get_throttle_interval(); | 10 double throttle_interval = ExtensionIdleCache::get_throttle_interval(); |
| 11 int min_threshold = ExtensionIdleCache::get_min_threshold(); | 11 int min_threshold = ExtensionIdleCache::get_min_threshold(); |
| 12 double now = 10 * min_threshold; | 12 double now = 10 * min_threshold; |
| 13 | 13 |
| 14 EXPECT_EQ(IDLE_STATE_UNKNOWN, | 14 EXPECT_EQ(IDLE_STATE_UNKNOWN, |
| 15 ExtensionIdleCache::CalculateState(min_threshold, now)); | 15 ExtensionIdleCache::CalculateState(min_threshold, now)); |
| 16 | 16 |
| 17 ExtensionIdleCache::Update(2 * min_threshold, IDLE_STATE_IDLE, now); | 17 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); | 112 ExtensionIdleCache::Update(2 * min_threshold, IDLE_STATE_LOCKED, now); |
| 113 | 113 |
| 114 now += 0.2 * throttle_interval; | 114 now += 0.2 * throttle_interval; |
| 115 ExtensionIdleCache::Update(4 * min_threshold, IDLE_STATE_ACTIVE, now); | 115 ExtensionIdleCache::Update(4 * min_threshold, IDLE_STATE_ACTIVE, now); |
| 116 | 116 |
| 117 // Last reported state was ACTIVE. | 117 // Last reported state was ACTIVE. |
| 118 EXPECT_EQ(IDLE_STATE_ACTIVE, | 118 EXPECT_EQ(IDLE_STATE_ACTIVE, |
| 119 ExtensionIdleCache::CalculateState(6 * min_threshold, | 119 ExtensionIdleCache::CalculateState(6 * min_threshold, |
| 120 now + 0.3 * throttle_interval)); | 120 now + 0.3 * throttle_interval)); |
| 121 } | 121 } |
| OLD | NEW |