OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "chrome/browser/sessions/session_restore_stats_collector.h" | 5 #include "chrome/browser/sessions/session_restore_stats_collector.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 | 189 |
190 // Ownership of the reporting delegate is passed to the | 190 // Ownership of the reporting delegate is passed to the |
191 // SessionRestoreStatsCollector, but a raw pointer is kept to it so it can | 191 // SessionRestoreStatsCollector, but a raw pointer is kept to it so it can |
192 // be queried by the test. | 192 // be queried by the test. |
193 passthrough_reporting_delegate_ = new PassthroughStatsReportingDelegate(); | 193 passthrough_reporting_delegate_ = new PassthroughStatsReportingDelegate(); |
194 | 194 |
195 // Ownership of this clock is passed to the SessionRestoreStatsCollector. | 195 // Ownership of this clock is passed to the SessionRestoreStatsCollector. |
196 // A raw pointer is kept to it so that it can be modified from the outside. | 196 // A raw pointer is kept to it so that it can be modified from the outside. |
197 // The unittest must take care to access the clock only while the | 197 // The unittest must take care to access the clock only while the |
198 // SessionRestoreStatsCollector under test is still alive. | 198 // SessionRestoreStatsCollector under test is still alive. |
199 test_tick_clock_ = new base::SimpleTestTickClock(); | 199 test_tick_clock_ = new base::SimpleTestTickClock(base::TimeTicks()); |
200 | 200 |
201 // Create a stats collector, keep a raw pointer to it, and detach from it. | 201 // Create a stats collector, keep a raw pointer to it, and detach from it. |
202 // The stats collector will stay alive as long as it has not yet completed | 202 // The stats collector will stay alive as long as it has not yet completed |
203 // its job, and will clean itself up when done. | 203 // its job, and will clean itself up when done. |
204 scoped_refptr<TestSessionRestoreStatsCollector> stats_collector = | 204 scoped_refptr<TestSessionRestoreStatsCollector> stats_collector = |
205 new TestSessionRestoreStatsCollector( | 205 new TestSessionRestoreStatsCollector( |
206 scoped_ptr<base::TickClock>(test_tick_clock_), | 206 scoped_ptr<base::TickClock>(test_tick_clock_), |
207 scoped_ptr<StatsReportingDelegate>( | 207 scoped_ptr<StatsReportingDelegate>( |
208 passthrough_reporting_delegate_)); | 208 passthrough_reporting_delegate_)); |
209 stats_collector_ = stats_collector.get(); | 209 stats_collector_ = stats_collector.get(); |
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
631 mock_reporting_delegate.ExpectReportTabLoaderStatsCalled(2, 1, 1, 0, 0, 0, 0, | 631 mock_reporting_delegate.ExpectReportTabLoaderStatsCalled(2, 1, 1, 0, 0, 0, 0, |
632 1); | 632 1); |
633 mock_reporting_delegate.EnsureNoUnexpectedCalls(); | 633 mock_reporting_delegate.EnsureNoUnexpectedCalls(); |
634 | 634 |
635 // Destroy the background tab. The collector should release itself. | 635 // Destroy the background tab. The collector should release itself. |
636 Tick(); // 3 ms. | 636 Tick(); // 3 ms. |
637 GenerateWebContentsDestroyed(1); | 637 GenerateWebContentsDestroyed(1); |
638 mock_reporting_delegate.ExpectReportStatsCollectorDeathCalled(); | 638 mock_reporting_delegate.ExpectReportStatsCollectorDeathCalled(); |
639 mock_reporting_delegate.EnsureNoUnexpectedCalls(); | 639 mock_reporting_delegate.EnsureNoUnexpectedCalls(); |
640 } | 640 } |
OLD | NEW |