| Index: chrome/browser/task_manager/sampling/shared_sampler_unittest_win.cc
|
| diff --git a/chrome/browser/task_manager/sampling/shared_sampler_unittest_win.cc b/chrome/browser/task_manager/sampling/shared_sampler_unittest_win.cc
|
| index 760e9dfd69785bc1875c5e3a2660591a411946b8..024fc84425930f15e16f03945670aab2fd766c74 100644
|
| --- a/chrome/browser/task_manager/sampling/shared_sampler_unittest_win.cc
|
| +++ b/chrome/browser/task_manager/sampling/shared_sampler_unittest_win.cc
|
| @@ -32,6 +32,10 @@ class SharedSamplerTest : public testing::Test {
|
| base::Bind(&SharedSamplerTest::OnIdleWakeupsRefreshDone,
|
| base::Unretained(this)),
|
| base::Bind(&SharedSamplerTest::OnPhysicalMemoryUsageRefreshDone,
|
| + base::Unretained(this)),
|
| + base::Bind(&SharedSamplerTest::OnStartTimeRefreshDone,
|
| + base::Unretained(this)),
|
| + base::Bind(&SharedSamplerTest::OnCpuTimeRefreshDone,
|
| base::Unretained(this)));
|
| }
|
|
|
| @@ -40,6 +44,10 @@ class SharedSamplerTest : public testing::Test {
|
| protected:
|
| int64_t physical_bytes() const { return physical_bytes_; }
|
|
|
| + int64_t start_time() const { return start_time_; }
|
| +
|
| + int64_t cpu_time() const { return cpu_time_; }
|
| +
|
| int idle_wakeups_per_second() const { return idle_wakeups_per_second_; }
|
|
|
| int64_t finished_refresh_type() const { return finished_refresh_type_; }
|
| @@ -81,12 +89,24 @@ class SharedSamplerTest : public testing::Test {
|
| OnRefreshTypeFinished(REFRESH_TYPE_IDLE_WAKEUPS);
|
| }
|
|
|
| + void OnStartTimeRefreshDone(int64_t start_time) {
|
| + start_time_ = start_time;
|
| + OnRefreshTypeFinished(REFRESH_TYPE_START_TIME);
|
| + }
|
| +
|
| + void OnCpuTimeRefreshDone(int64_t cpu_time) {
|
| + cpu_time_ = cpu_time;
|
| + OnRefreshTypeFinished(REFRESH_TYPE_CPU_TIME);
|
| + }
|
| +
|
| int64_t expected_refresh_type_ = 0;
|
| int64_t finished_refresh_type_ = 0;
|
| base::Closure quit_closure_;
|
|
|
| int64_t physical_bytes_ = 0;
|
| int idle_wakeups_per_second_ = -1;
|
| + int64_t start_time_ = -1;
|
| + int64_t cpu_time_ = -1;
|
|
|
| content::TestBrowserThreadBundle thread_bundle_;
|
| scoped_refptr<base::SequencedTaskRunner> blocking_pool_runner_;
|
| @@ -136,11 +156,50 @@ TEST_F(SharedSamplerTest, PhysicalMemory) {
|
| EXPECT_GE(physical_bytes(), initial_value + allocated_size);
|
| }
|
|
|
| +// Tests that process start time can be obtained from SharedSampler.
|
| +TEST_F(SharedSamplerTest, StartTime) {
|
| + StartRefresh(REFRESH_TYPE_START_TIME);
|
| + WaitUntilRefreshDone();
|
| + EXPECT_EQ(REFRESH_TYPE_START_TIME, finished_refresh_type());
|
| +
|
| + // Should get a greater than zero now.
|
| + int64_t start_time_prev = start_time();
|
| + EXPECT_GT(start_time_prev, 0);
|
| +
|
| + // Do a refresh.
|
| + StartRefresh(REFRESH_TYPE_START_TIME);
|
| + WaitUntilRefreshDone();
|
| +
|
| + // Start time should not change.
|
| + EXPECT_EQ(start_time(), start_time_prev);
|
| +}
|
| +
|
| +// Tests that CPU time can be obtained from SharedSampler.
|
| +TEST_F(SharedSamplerTest, CpuTime) {
|
| + StartRefresh(REFRESH_TYPE_CPU_TIME);
|
| + WaitUntilRefreshDone();
|
| + EXPECT_EQ(REFRESH_TYPE_CPU_TIME, finished_refresh_type());
|
| +
|
| + // Should get a greater than or equal to zero now.
|
| + int64_t cpu_time_prev = cpu_time();
|
| + EXPECT_GE(cpu_time_prev, 0);
|
| +
|
| + // Do a refresh.
|
| + StartRefresh(REFRESH_TYPE_CPU_TIME);
|
| + WaitUntilRefreshDone();
|
| +
|
| + // CPU time should not decrease.
|
| + EXPECT_GE(cpu_time(), cpu_time_prev);
|
| +}
|
| +
|
| +
|
| // Verifies that multiple refresh types can be refreshed at the same time.
|
| TEST_F(SharedSamplerTest, MultipleRefreshTypes) {
|
| - StartRefresh(REFRESH_TYPE_IDLE_WAKEUPS | REFRESH_TYPE_PHYSICAL_MEMORY);
|
| + StartRefresh(REFRESH_TYPE_IDLE_WAKEUPS | REFRESH_TYPE_PHYSICAL_MEMORY |
|
| + REFRESH_TYPE_START_TIME | REFRESH_TYPE_CPU_TIME);
|
| WaitUntilRefreshDone();
|
| - EXPECT_EQ(REFRESH_TYPE_IDLE_WAKEUPS | REFRESH_TYPE_PHYSICAL_MEMORY,
|
| + EXPECT_EQ(REFRESH_TYPE_IDLE_WAKEUPS | REFRESH_TYPE_PHYSICAL_MEMORY |
|
| + REFRESH_TYPE_START_TIME | REFRESH_TYPE_CPU_TIME,
|
| finished_refresh_type());
|
| }
|
|
|
|
|