| 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 <algorithm> | 5 #include <algorithm> |
| 6 | 6 |
| 7 #include "base/rand_util.h" | 7 #include "base/rand_util.h" |
| 8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
| 9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
| 10 #include "chrome/browser/apps/ephemeral_app_service.h" | 10 #include "chrome/browser/apps/ephemeral_app_service.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 removed_apps.insert(*it); | 66 removed_apps.insert(*it); |
| 67 launch_times.erase(it++); | 67 launch_times.erase(it++); |
| 68 } else { | 68 } else { |
| 69 ++it; | 69 ++it; |
| 70 } | 70 } |
| 71 } | 71 } |
| 72 | 72 |
| 73 if (launch_times.empty()) | 73 if (launch_times.empty()) |
| 74 return; | 74 return; |
| 75 | 75 |
| 76 // Verify that the removed apps have launch times earlier than all retained | 76 // Verify that the removed apps have launch times earlier than or equal to |
| 77 // apps. We can actually just compare with the first entry in |launch_times| | 77 // all retained apps. We can actually just compare with the first entry in |
| 78 // but will make no implementation assumptions. | 78 // |launch_times| but will make no implementation assumptions. |
| 79 for (LaunchTimeAppMap::const_iterator removed = removed_apps.begin(); | 79 for (LaunchTimeAppMap::const_iterator removed = removed_apps.begin(); |
| 80 removed != removed_apps.end(); ++removed) { | 80 removed != removed_apps.end(); ++removed) { |
| 81 for (LaunchTimeAppMap::iterator retained = launch_times.begin(); | 81 for (LaunchTimeAppMap::iterator retained = launch_times.begin(); |
| 82 retained != launch_times.end(); ++retained) { | 82 retained != launch_times.end(); ++retained) { |
| 83 EXPECT_TRUE(removed->first < retained->first); | 83 EXPECT_LE(removed->first, retained->first); |
| 84 } | 84 } |
| 85 } | 85 } |
| 86 } | 86 } |
| 87 | 87 |
| 88 // Generate X app launch times, N days before the reference time. | 88 // Generate X app launch times, N days before the reference time. |
| 89 // If |generated_ids| is not NULL, the generated app IDs will be added | 89 // If |generated_ids| is not NULL, the generated app IDs will be added |
| 90 // to the set. | 90 // to the set. |
| 91 void GenerateLaunchTimes(const base::Time& reference_time, | 91 void GenerateLaunchTimes(const base::Time& reference_time, |
| 92 int days_before, | 92 int days_before, |
| 93 int count, | 93 int count, |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 const int kRunningApps = 3; | 257 const int kRunningApps = 3; |
| 258 AddIntermediateApps( | 258 AddIntermediateApps( |
| 259 time_now, | 259 time_now, |
| 260 EphemeralAppService::kMaxEphemeralAppsCount, | 260 EphemeralAppService::kMaxEphemeralAppsCount, |
| 261 &launch_times); // overflow | 261 &launch_times); // overflow |
| 262 RunTestCheckLRU( | 262 RunTestCheckLRU( |
| 263 launch_times.size() + kRunningApps, | 263 launch_times.size() + kRunningApps, |
| 264 launch_times, | 264 launch_times, |
| 265 kRunningApps); | 265 kRunningApps); |
| 266 } | 266 } |
| OLD | NEW |