Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(146)

Side by Side Diff: chrome/browser/autocomplete/network_action_predictor_unittest.cc

Issue 7833046: Changing confidence calculation to avoid div by zero (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Tweaking math and unit test expectations Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/autocomplete/network_action_predictor.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/network_action_predictor.h" 5 #include "chrome/browser/autocomplete/network_action_predictor.h"
6 6
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/time.h" 8 #include "base/time.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/autocomplete/autocomplete_match.h" 10 #include "chrome/browser/autocomplete/autocomplete_match.h"
(...skipping 29 matching lines...) Expand all
40 string16 user_text; 40 string16 user_text;
41 NetworkActionPredictor::Action expected_action; 41 NetworkActionPredictor::Action expected_action;
42 } test_url_db[] = { 42 } test_url_db[] = {
43 { GURL("http://www.testsite.com/a.html"), 43 { GURL("http://www.testsite.com/a.html"),
44 ASCIIToUTF16("Test - site - just a test"), 1, 1, 44 ASCIIToUTF16("Test - site - just a test"), 1, 1,
45 ASCIIToUTF16("just"), 45 ASCIIToUTF16("just"),
46 NetworkActionPredictor::ACTION_PRERENDER }, 46 NetworkActionPredictor::ACTION_PRERENDER },
47 { GURL("http://www.testsite.com/b.html"), 47 { GURL("http://www.testsite.com/b.html"),
48 ASCIIToUTF16("Test - site - just a test"), 0, 1, 48 ASCIIToUTF16("Test - site - just a test"), 0, 1,
49 ASCIIToUTF16("just"), 49 ASCIIToUTF16("just"),
50 NetworkActionPredictor::ACTION_NONE }, 50 NetworkActionPredictor::ACTION_PRERENDER },
51 { GURL("http://www.testsite.com/c.html"), 51 { GURL("http://www.testsite.com/c.html"),
52 ASCIIToUTF16("Test - site - just a test"), 1, 5, 52 ASCIIToUTF16("Test - site - just a test"), 1, 5,
53 ASCIIToUTF16("just"), 53 ASCIIToUTF16("just"),
54 NetworkActionPredictor::ACTION_PRERENDER }, 54 NetworkActionPredictor::ACTION_PRECONNECT },
55 { GURL("http://www.testsite.com/d.html"), 55 { GURL("http://www.testsite.com/d.html"),
56 ASCIIToUTF16("Test - site - just a test"), 2, 5, 56 ASCIIToUTF16("Test - site - just a test"), 2, 5,
57 ASCIIToUTF16("just"), 57 ASCIIToUTF16("just"),
58 NetworkActionPredictor::ACTION_PRERENDER }, 58 NetworkActionPredictor::ACTION_PRERENDER },
59 { GURL("http://www.testsite.com/e.html"), 59 { GURL("http://www.testsite.com/e.html"),
60 ASCIIToUTF16("Test - site - just a test"), 1, 8, 60 ASCIIToUTF16("Test - site - just a test"), 1, 8,
61 ASCIIToUTF16("just"), 61 ASCIIToUTF16("just"),
62 NetworkActionPredictor::ACTION_PRECONNECT }, 62 NetworkActionPredictor::ACTION_PRECONNECT },
63 { GURL("http://www.testsite.com/f.html"), 63 { GURL("http://www.testsite.com/f.html"),
64 ASCIIToUTF16("Test - site - just a test"), 4, 8, 64 ASCIIToUTF16("Test - site - just a test"), 4, 8,
65 ASCIIToUTF16("just"), 65 ASCIIToUTF16("just"),
66 NetworkActionPredictor::ACTION_PRERENDER }, 66 NetworkActionPredictor::ACTION_PRERENDER },
67 { GURL("http://www.testsite.com/g.html"), 67 { GURL("http://www.testsite.com/g.html"),
68 ASCIIToUTF16("Test - site - just a test"), 1, 12, 68 ASCIIToUTF16("Test - site - just a test"), 1, 12,
69 ASCIIToUTF16("just a"), 69 ASCIIToUTF16("just a"),
70 NetworkActionPredictor::ACTION_PRECONNECT }, 70 NetworkActionPredictor::ACTION_NONE },
71 { GURL("http://www.testsite.com/h.html"), 71 { GURL("http://www.testsite.com/h.html"),
72 ASCIIToUTF16("Test - site - just a test"), 1, 21, 72 ASCIIToUTF16("Test - site - just a test"), 2, 21,
73 ASCIIToUTF16("just a test"), 73 ASCIIToUTF16("just a test"),
74 NetworkActionPredictor::ACTION_PRECONNECT }, 74 NetworkActionPredictor::ACTION_NONE },
75 { GURL("http://www.testsite.com/i.html"), 75 { GURL("http://www.testsite.com/i.html"),
76 ASCIIToUTF16("Test - site - just a test"), 1, 28, 76 ASCIIToUTF16("Test - site - just a test"), 3, 28,
77 ASCIIToUTF16("just a test"), 77 ASCIIToUTF16("just a test"),
78 NetworkActionPredictor::ACTION_NONE } 78 NetworkActionPredictor::ACTION_NONE }
79 }; 79 };
80 80
81 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_url_db); ++i) { 81 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_url_db); ++i) {
82 const base::Time visit_time = 82 const base::Time visit_time =
83 base::Time::Now() - base::TimeDelta::FromDays( 83 base::Time::Now() - base::TimeDelta::FromDays(
84 test_url_db[i].days_from_now); 84 test_url_db[i].days_from_now);
85 85
86 history::URLRow row(test_url_db[i].url); 86 history::URLRow row(test_url_db[i].url);
87 row.set_title(test_url_db[i].title); 87 row.set_title(test_url_db[i].title);
88 row.set_typed_count(test_url_db[i].typed_count); 88 row.set_typed_count(test_url_db[i].typed_count);
89 row.set_last_visit(visit_time); 89 row.set_last_visit(visit_time);
90 90
91 CHECK(url_db->AddURL(row)); 91 CHECK(url_db->AddURL(row));
92 } 92 }
93 93
94 AutocompleteMatch match; 94 AutocompleteMatch match;
95 95
96 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_url_db); ++i) { 96 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_url_db); ++i) {
97 match.destination_url = GURL(test_url_db[i].url); 97 match.destination_url = GURL(test_url_db[i].url);
98 EXPECT_EQ(test_url_db[i].expected_action, 98 EXPECT_EQ(test_url_db[i].expected_action,
99 predictor.RecommendAction(test_url_db[i].user_text, match)) 99 predictor.RecommendAction(test_url_db[i].user_text, match))
100 << "Unexpected action for " << match.destination_url; 100 << "Unexpected action for " << match.destination_url;
101 } 101 }
102 } 102 }
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/network_action_predictor.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698