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/network_action_predictor.h" | 5 #include "chrome/browser/autocomplete/network_action_predictor.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 GURL url; | 31 GURL url; |
32 string16 title; | 32 string16 title; |
33 int days_from_now; | 33 int days_from_now; |
34 string16 user_text; | 34 string16 user_text; |
35 int number_of_hits; | 35 int number_of_hits; |
36 int number_of_misses; | 36 int number_of_misses; |
37 NetworkActionPredictor::Action expected_action; | 37 NetworkActionPredictor::Action expected_action; |
38 } test_url_db[] = { | 38 } test_url_db[] = { |
39 { GURL("http://www.testsite.com/a.html"), | 39 { GURL("http://www.testsite.com/a.html"), |
40 ASCIIToUTF16("Test - site - just a test"), 1, | 40 ASCIIToUTF16("Test - site - just a test"), 1, |
41 ASCIIToUTF16("just"), 5, 0, | 41 ASCIIToUTF16("j"), 5, 0, |
42 NetworkActionPredictor::ACTION_PRERENDER }, | 42 NetworkActionPredictor::ACTION_PRERENDER }, |
43 { GURL("http://www.testsite.com/b.html"), | 43 { GURL("http://www.testsite.com/b.html"), |
44 ASCIIToUTF16("Test - site - just a test"), 1, | 44 ASCIIToUTF16("Test - site - just a test"), 1, |
45 ASCIIToUTF16("just"), 3, 0, | 45 ASCIIToUTF16("ju"), 3, 0, |
46 NetworkActionPredictor::ACTION_PRERENDER }, | 46 NetworkActionPredictor::ACTION_PRERENDER }, |
47 { GURL("http://www.testsite.com/c.html"), | 47 { GURL("http://www.testsite.com/c.html"), |
48 ASCIIToUTF16("Test - site - just a test"), 5, | 48 ASCIIToUTF16("Test - site - just a test"), 5, |
49 ASCIIToUTF16("just"), 3, 1, | 49 ASCIIToUTF16("just"), 3, 1, |
50 NetworkActionPredictor::ACTION_PRECONNECT }, | 50 NetworkActionPredictor::ACTION_PRECONNECT }, |
51 { GURL("http://www.testsite.com/d.html"), | 51 { GURL("http://www.testsite.com/d.html"), |
52 ASCIIToUTF16("Test - site - just a test"), 5, | 52 ASCIIToUTF16("Test - site - just a test"), 5, |
53 ASCIIToUTF16("just"), 3, 0, | 53 ASCIIToUTF16("just"), 3, 0, |
54 NetworkActionPredictor::ACTION_PRERENDER }, | 54 NetworkActionPredictor::ACTION_PRERENDER }, |
55 { GURL("http://www.testsite.com/e.html"), | 55 { GURL("http://www.testsite.com/e.html"), |
56 ASCIIToUTF16("Test - site - just a test"), 8, | 56 ASCIIToUTF16("Test - site - just a test"), 8, |
57 ASCIIToUTF16("just"), 3, 1, | 57 ASCIIToUTF16("just"), 3, 1, |
58 NetworkActionPredictor::ACTION_PRECONNECT }, | 58 NetworkActionPredictor::ACTION_PRECONNECT }, |
59 { GURL("http://www.testsite.com/f.html"), | 59 { GURL("http://www.testsite.com/f.html"), |
60 ASCIIToUTF16("Test - site - just a test"), 8, | 60 ASCIIToUTF16("Test - site - just a test"), 8, |
61 ASCIIToUTF16("just"), 3, 0, | 61 ASCIIToUTF16("just"), 3, 0, |
62 NetworkActionPredictor::ACTION_PRERENDER }, | 62 NetworkActionPredictor::ACTION_PRERENDER }, |
63 { GURL("http://www.testsite.com/g.html"), | 63 { GURL("http://www.testsite.com/g.html"), |
64 ASCIIToUTF16("Test - site - just a test"), 12, | 64 ASCIIToUTF16("Test - site - just a test"), 12, |
65 ASCIIToUTF16("j"), 5, 0, | 65 ASCIIToUTF16(""), 5, 0, |
66 NetworkActionPredictor::ACTION_NONE }, | 66 NetworkActionPredictor::ACTION_NONE }, |
67 { GURL("http://www.testsite.com/h.html"), | 67 { GURL("http://www.testsite.com/h.html"), |
68 ASCIIToUTF16("Test - site - just a test"), 21, | 68 ASCIIToUTF16("Test - site - just a test"), 21, |
69 ASCIIToUTF16("just a test"), 2, 0, | 69 ASCIIToUTF16("just a test"), 2, 0, |
70 NetworkActionPredictor::ACTION_NONE }, | 70 NetworkActionPredictor::ACTION_NONE }, |
71 { GURL("http://www.testsite.com/i.html"), | 71 { GURL("http://www.testsite.com/i.html"), |
72 ASCIIToUTF16("Test - site - just a test"), 28, | 72 ASCIIToUTF16("Test - site - just a test"), 28, |
73 ASCIIToUTF16("just a test"), 2, 0, | 73 ASCIIToUTF16("just a test"), 2, 0, |
74 NetworkActionPredictor::ACTION_NONE } | 74 NetworkActionPredictor::ACTION_NONE } |
75 }; | 75 }; |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 (test_url_db[i].expected_action == | 360 (test_url_db[i].expected_action == |
361 NetworkActionPredictor::ACTION_PRERENDER) ? | 361 NetworkActionPredictor::ACTION_PRERENDER) ? |
362 NetworkActionPredictor::ACTION_PRECONNECT : | 362 NetworkActionPredictor::ACTION_PRECONNECT : |
363 test_url_db[i].expected_action; | 363 test_url_db[i].expected_action; |
364 | 364 |
365 EXPECT_EQ(expected, | 365 EXPECT_EQ(expected, |
366 predictor()->RecommendAction(test_url_db[i].user_text, match)) | 366 predictor()->RecommendAction(test_url_db[i].user_text, match)) |
367 << "Unexpected action for " << match.destination_url; | 367 << "Unexpected action for " << match.destination_url; |
368 } | 368 } |
369 } | 369 } |
OLD | NEW |