Chromium Code Reviews| 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/test/simple_test_clock.h" | 6 #include "base/test/simple_test_clock.h" |
| 7 #include "base/values.h" | 7 #include "base/values.h" |
| 8 #include "chrome/browser/engagement/site_engagement_helper.h" | 8 #include "chrome/browser/engagement/site_engagement_helper.h" |
| 9 #include "chrome/browser/engagement/site_engagement_service.h" | 9 #include "chrome/browser/engagement/site_engagement_service.h" |
| 10 #include "chrome/browser/engagement/site_engagement_service_factory.h" | 10 #include "chrome/browser/engagement/site_engagement_service_factory.h" |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 327 EXPECT_EQ(0, service->GetScore(url)); | 327 EXPECT_EQ(0, service->GetScore(url)); |
| 328 int prev_score = service->GetScore(url); | 328 int prev_score = service->GetScore(url); |
| 329 | 329 |
| 330 NavigateAndCommitActiveTab(url); | 330 NavigateAndCommitActiveTab(url); |
| 331 EXPECT_LT(prev_score, service->GetScore(url)); | 331 EXPECT_LT(prev_score, service->GetScore(url)); |
| 332 prev_score = service->GetScore(url); | 332 prev_score = service->GetScore(url); |
| 333 | 333 |
| 334 NavigateAndCommitActiveTab(url); | 334 NavigateAndCommitActiveTab(url); |
| 335 EXPECT_LT(prev_score, service->GetScore(url)); | 335 EXPECT_LT(prev_score, service->GetScore(url)); |
| 336 } | 336 } |
| 337 | |
| 338 // Expect that site engagement | |
|
raymes
2015/07/06 02:50:51
nit: this comment looks unfinished
calamity
2015/07/07 02:47:25
Oops.
| |
| 339 TEST_F(SiteEngagementServiceTest, GetTotalEngagementPoints) { | |
| 340 base::CommandLine::ForCurrentProcess()->AppendSwitch( | |
| 341 switches::kEnableSiteEngagementService); | |
|
raymes
2015/07/06 02:50:51
nit: we should probably just move this into SetUp(
calamity
2015/07/07 02:47:25
Done.
| |
| 342 | |
| 343 SiteEngagementService* service = | |
| 344 SiteEngagementServiceFactory::GetForProfile(profile()); | |
| 345 DCHECK(service); | |
| 346 | |
| 347 // The https and http versions of www.google.com should be separate. | |
| 348 GURL url1("https://www.google.com/"); | |
| 349 GURL url2("http://www.google.com/"); | |
| 350 GURL url3("http://m.xkcd.com/"); | |
| 351 | |
| 352 EXPECT_EQ(0, service->GetScore(url1)); | |
| 353 EXPECT_EQ(0, service->GetScore(url2)); | |
| 354 EXPECT_EQ(0, service->GetScore(url3)); | |
| 355 | |
| 356 service->HandleNavigation(url1); | |
| 357 EXPECT_EQ(1, service->GetScore(url1)); | |
| 358 EXPECT_EQ(1, service->GetTotalEngagementPoints()); | |
| 359 | |
| 360 service->HandleNavigation(url2); | |
| 361 service->HandleNavigation(url2); | |
| 362 EXPECT_EQ(2, service->GetScore(url2)); | |
| 363 EXPECT_EQ(3, service->GetTotalEngagementPoints()); | |
| 364 | |
| 365 service->HandleNavigation(url3); | |
| 366 EXPECT_EQ(1, service->GetScore(url3)); | |
| 367 EXPECT_EQ(4, service->GetTotalEngagementPoints()); | |
| 368 | |
| 369 service->HandleNavigation(url1); | |
| 370 service->HandleNavigation(url1); | |
| 371 EXPECT_EQ(3, service->GetScore(url1)); | |
| 372 EXPECT_EQ(6, service->GetTotalEngagementPoints()); | |
| 373 } | |
| OLD | NEW |