| 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/android/data_usage/tab_data_use_entry.h" | 5 #include "chrome/browser/android/data_usage/tab_data_use_entry.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 // Pointer to the clock used for spoofing time, owned by |tab_model_|. | 156 // Pointer to the clock used for spoofing time, owned by |tab_model_|. |
| 157 SimpleOffsetTestTickClock* tick_clock_; | 157 SimpleOffsetTestTickClock* tick_clock_; |
| 158 | 158 |
| 159 std::unique_ptr<DataUseTabModel> tab_model_; | 159 std::unique_ptr<DataUseTabModel> tab_model_; |
| 160 std::unique_ptr<TabDataUseEntry> tab_entry_; | 160 std::unique_ptr<TabDataUseEntry> tab_entry_; |
| 161 | 161 |
| 162 DISALLOW_COPY_AND_ASSIGN(TabDataUseEntryTest); | 162 DISALLOW_COPY_AND_ASSIGN(TabDataUseEntryTest); |
| 163 }; | 163 }; |
| 164 | 164 |
| 165 // Starts a single tracking session and checks if a new active session is added | 165 // Starts a single tracking session and checks if a new active session is added |
| 166 // to the deque. Ends the session and checks if it becomes inactive. | 166 // to the vector. Ends the session and checks if it becomes inactive. |
| 167 TEST_F(TabDataUseEntryTest, SingleTabSessionStartEnd) { | 167 TEST_F(TabDataUseEntryTest, SingleTabSessionStartEnd) { |
| 168 ExpectTabEntrySessionsSize(TabEntrySessionSize::ZERO); | 168 ExpectTabEntrySessionsSize(TabEntrySessionSize::ZERO); |
| 169 EXPECT_FALSE(tab_entry_->IsTrackingDataUse()); | 169 EXPECT_FALSE(tab_entry_->IsTrackingDataUse()); |
| 170 | 170 |
| 171 EXPECT_TRUE(tab_entry_->StartTracking(kTestLabel1)); | 171 EXPECT_TRUE(tab_entry_->StartTracking(kTestLabel1)); |
| 172 ExpectTabEntrySessionsSize(TabEntrySessionSize::ONE); | 172 ExpectTabEntrySessionsSize(TabEntrySessionSize::ONE); |
| 173 EXPECT_TRUE(tab_entry_->IsTrackingDataUse()); | 173 EXPECT_TRUE(tab_entry_->IsTrackingDataUse()); |
| 174 | 174 |
| 175 EXPECT_TRUE(tab_entry_->EndTracking()); | 175 EXPECT_TRUE(tab_entry_->EndTracking()); |
| 176 ExpectTabEntrySessionsSize(TabEntrySessionSize::ONE); | 176 ExpectTabEntrySessionsSize(TabEntrySessionSize::ONE); |
| 177 EXPECT_FALSE(tab_entry_->IsTrackingDataUse()); | 177 EXPECT_FALSE(tab_entry_->IsTrackingDataUse()); |
| 178 } | 178 } |
| 179 | 179 |
| 180 // Starts multiple tracking sessions and checks if new active sessions are added | 180 // Starts multiple tracking sessions and checks if new active sessions are added |
| 181 // to the deque for each. Ends the sessions and checks if they become inactive. | 181 // to the vector for each. Ends the sessions and checks if they become inactive. |
| 182 TEST_F(TabDataUseEntryTest, MultipleTabSessionStartEnd) { | 182 TEST_F(TabDataUseEntryTest, MultipleTabSessionStartEnd) { |
| 183 ExpectTabEntrySessionsSize(TabEntrySessionSize::ZERO); | 183 ExpectTabEntrySessionsSize(TabEntrySessionSize::ZERO); |
| 184 EXPECT_FALSE(tab_entry_->IsTrackingDataUse()); | 184 EXPECT_FALSE(tab_entry_->IsTrackingDataUse()); |
| 185 | 185 |
| 186 EXPECT_TRUE(tab_entry_->StartTracking(kTestLabel1)); | 186 EXPECT_TRUE(tab_entry_->StartTracking(kTestLabel1)); |
| 187 EXPECT_TRUE(tab_entry_->IsTrackingDataUse()); | 187 EXPECT_TRUE(tab_entry_->IsTrackingDataUse()); |
| 188 EXPECT_TRUE(tab_entry_->EndTracking()); | 188 EXPECT_TRUE(tab_entry_->EndTracking()); |
| 189 EXPECT_FALSE(tab_entry_->IsTrackingDataUse()); | 189 EXPECT_FALSE(tab_entry_->IsTrackingDataUse()); |
| 190 | 190 |
| 191 EXPECT_TRUE(tab_entry_->StartTracking(kTestLabel2)); | 191 EXPECT_TRUE(tab_entry_->StartTracking(kTestLabel2)); |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 550 EXPECT_TRUE(tab_entry_->EndTracking()); | 550 EXPECT_TRUE(tab_entry_->EndTracking()); |
| 551 | 551 |
| 552 histogram_tester.ExpectUniqueSample( | 552 histogram_tester.ExpectUniqueSample( |
| 553 kUMAOldInactiveSessionRemovalDurationSecondsHistogram, | 553 kUMAOldInactiveSessionRemovalDurationSecondsHistogram, |
| 554 base::TimeDelta::FromSeconds(30).InMilliseconds(), 1); | 554 base::TimeDelta::FromSeconds(30).InMilliseconds(), 1); |
| 555 } | 555 } |
| 556 | 556 |
| 557 } // namespace android | 557 } // namespace android |
| 558 | 558 |
| 559 } // namespace chrome | 559 } // namespace chrome |
| OLD | NEW |