OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/autocomplete/history_quick_provider.h" | 5 #include "chrome/browser/autocomplete/history_quick_provider.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <functional> | 8 #include <functional> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 // Can inline, not clamped. | 357 // Can inline, not clamped. |
358 match.raw_score = 1425; | 358 match.raw_score = 1425; |
359 match.can_inline = true; | 359 match.can_inline = true; |
360 EXPECT_EQ(HistoryQuickProvider::CalculateRelevance(match, &next_score), 1425); | 360 EXPECT_EQ(HistoryQuickProvider::CalculateRelevance(match, &next_score), 1425); |
361 EXPECT_EQ(next_score, 1424); | 361 EXPECT_EQ(next_score, 1424); |
362 | 362 |
363 // Can't inline, not clamped. | 363 // Can't inline, not clamped. |
364 next_score = 1500; | 364 next_score = 1500; |
365 match.raw_score = 1425; | 365 match.raw_score = 1425; |
366 match.can_inline = false; | 366 match.can_inline = false; |
367 EXPECT_EQ(HistoryQuickProvider::CalculateRelevance(match, &next_score), 1199); | 367 EXPECT_EQ(HistoryQuickProvider::CalculateRelevance(match, &next_score), |
368 EXPECT_EQ(next_score, 1198); | 368 HistoryQuickProvider::kMaxNonInliningScore); |
| 369 EXPECT_EQ(next_score, HistoryQuickProvider::kMaxNonInliningScore - 1); |
369 | 370 |
370 // Can inline, clamped. | 371 // Can inline, clamped. |
371 next_score = 1199; | 372 next_score = HistoryQuickProvider::kMaxNonInliningScore; |
372 match.raw_score = 1425; | 373 match.raw_score = 1425; |
373 match.can_inline = true; | 374 match.can_inline = true; |
374 EXPECT_EQ(HistoryQuickProvider::CalculateRelevance(match, &next_score), 1199); | 375 EXPECT_EQ(HistoryQuickProvider::CalculateRelevance(match, &next_score), |
375 EXPECT_EQ(next_score, 1198); | 376 HistoryQuickProvider::kMaxNonInliningScore); |
| 377 EXPECT_EQ(next_score, HistoryQuickProvider::kMaxNonInliningScore - 1); |
376 | 378 |
377 // Can't inline, clamped. | 379 // Can't inline, clamped. |
378 next_score = 1199; | 380 next_score = HistoryQuickProvider::kMaxNonInliningScore; |
379 match.raw_score = 1425; | 381 match.raw_score = 1425; |
380 match.can_inline = false; | 382 match.can_inline = false; |
381 EXPECT_EQ(HistoryQuickProvider::CalculateRelevance(match, &next_score), 1199); | 383 EXPECT_EQ(HistoryQuickProvider::CalculateRelevance(match, &next_score), |
382 EXPECT_EQ(next_score, 1198); | 384 HistoryQuickProvider::kMaxNonInliningScore); |
| 385 EXPECT_EQ(next_score, HistoryQuickProvider::kMaxNonInliningScore - 1); |
383 | 386 |
384 // Score just above the clamped limit. | 387 // Score just above the clamped limit. |
385 next_score = 1199; | 388 next_score = HistoryQuickProvider::kMaxNonInliningScore; |
386 match.raw_score = 1200; | 389 match.raw_score = AutocompleteResult::kLowestDefaultScore; |
387 match.can_inline = false; | 390 match.can_inline = false; |
388 EXPECT_EQ(HistoryQuickProvider::CalculateRelevance(match, &next_score), 1199); | 391 EXPECT_EQ(HistoryQuickProvider::CalculateRelevance(match, &next_score), |
389 EXPECT_EQ(next_score, 1198); | 392 HistoryQuickProvider::kMaxNonInliningScore); |
| 393 EXPECT_EQ(next_score, HistoryQuickProvider::kMaxNonInliningScore - 1); |
390 | 394 |
391 // Score right at the clamped limit. | 395 // Score right at the clamped limit. |
392 next_score = 1199; | 396 next_score = HistoryQuickProvider::kMaxNonInliningScore; |
393 match.raw_score = 1199; | 397 match.raw_score = HistoryQuickProvider::kMaxNonInliningScore; |
394 match.can_inline = true; | 398 match.can_inline = true; |
395 EXPECT_EQ(HistoryQuickProvider::CalculateRelevance(match, &next_score), 1199); | 399 EXPECT_EQ(HistoryQuickProvider::CalculateRelevance(match, &next_score), |
396 EXPECT_EQ(next_score, 1198); | 400 HistoryQuickProvider::kMaxNonInliningScore); |
| 401 EXPECT_EQ(next_score, HistoryQuickProvider::kMaxNonInliningScore - 1); |
397 | 402 |
398 // Score just below the clamped limit. | 403 // Score just below the clamped limit. |
399 next_score = 1199; | 404 next_score = HistoryQuickProvider::kMaxNonInliningScore; |
400 match.raw_score = 1198; | 405 match.raw_score = HistoryQuickProvider::kMaxNonInliningScore - 1; |
401 match.can_inline = true; | 406 match.can_inline = true; |
402 EXPECT_EQ(HistoryQuickProvider::CalculateRelevance(match, &next_score), 1198); | 407 EXPECT_EQ(HistoryQuickProvider::CalculateRelevance(match, &next_score), |
403 EXPECT_EQ(next_score, 1197); | 408 HistoryQuickProvider::kMaxNonInliningScore - 1); |
| 409 EXPECT_EQ(next_score, HistoryQuickProvider::kMaxNonInliningScore - 2); |
404 | 410 |
405 // Low score, can inline, not clamped. | 411 // Low score, can inline, not clamped. |
406 next_score = 1500; | 412 next_score = 1500; |
407 match.raw_score = 500; | 413 match.raw_score = 500; |
408 match.can_inline = true; | 414 match.can_inline = true; |
409 EXPECT_EQ(HistoryQuickProvider::CalculateRelevance(match, &next_score), 500); | 415 EXPECT_EQ(HistoryQuickProvider::CalculateRelevance(match, &next_score), 500); |
410 EXPECT_EQ(next_score, 499); | 416 EXPECT_EQ(next_score, 499); |
411 } | 417 } |
OLD | NEW |