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 "base/file_util.h" | 5 #include "base/file_util.h" |
6 #include "base/path_service.h" | 6 #include "base/path_service.h" |
7 #include "base/string_number_conversions.h" | 7 #include "base/string_number_conversions.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/common/chrome_paths.h" | 10 #include "chrome/common/chrome_paths.h" |
11 #include "chrome/browser/search_engines/template_url.h" | 11 #include "chrome/browser/search_engines/template_url.h" |
12 #include "chrome/browser/webdata/web_database.h" | 12 #include "chrome/browser/webdata/web_database.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
14 | 14 |
15 using base::Time; | 15 using base::Time; |
| 16 using base::TimeDelta; |
16 | 17 |
17 class KeywordTableTest : public testing::Test { | 18 class KeywordTableTest : public testing::Test { |
18 public: | 19 public: |
19 KeywordTableTest() {} | 20 KeywordTableTest() {} |
20 virtual ~KeywordTableTest() {} | 21 virtual ~KeywordTableTest() {} |
21 | 22 |
22 protected: | 23 protected: |
23 virtual void SetUp() { | 24 virtual void SetUp() { |
24 PathService::Get(chrome::DIR_TEST_DATA, &file_); | 25 PathService::Get(chrome::DIR_TEST_DATA, &file_); |
25 const std::string test_db = "TestWebDatabase" + | 26 const std::string test_db = "TestWebDatabase" + |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 TemplateURL template_url; | 65 TemplateURL template_url; |
65 template_url.set_short_name(ASCIIToUTF16("short_name")); | 66 template_url.set_short_name(ASCIIToUTF16("short_name")); |
66 template_url.set_keyword(ASCIIToUTF16("keyword")); | 67 template_url.set_keyword(ASCIIToUTF16("keyword")); |
67 GURL favicon_url("http://favicon.url/"); | 68 GURL favicon_url("http://favicon.url/"); |
68 GURL originating_url("http://google.com/"); | 69 GURL originating_url("http://google.com/"); |
69 template_url.SetFaviconURL(favicon_url); | 70 template_url.SetFaviconURL(favicon_url); |
70 template_url.SetURL("http://url/", 0, 0); | 71 template_url.SetURL("http://url/", 0, 0); |
71 template_url.set_safe_for_autoreplace(true); | 72 template_url.set_safe_for_autoreplace(true); |
72 Time created_time = Time::Now(); | 73 Time created_time = Time::Now(); |
73 template_url.set_date_created(created_time); | 74 template_url.set_date_created(created_time); |
| 75 Time last_modified_time = created_time + TimeDelta::FromSeconds(10); |
| 76 template_url.set_last_modified(last_modified_time); |
74 template_url.set_show_in_default_list(true); | 77 template_url.set_show_in_default_list(true); |
75 template_url.set_originating_url(originating_url); | 78 template_url.set_originating_url(originating_url); |
76 template_url.set_usage_count(32); | 79 template_url.set_usage_count(32); |
77 template_url.add_input_encoding("UTF-8"); | 80 template_url.add_input_encoding("UTF-8"); |
78 template_url.add_input_encoding("UTF-16"); | 81 template_url.add_input_encoding("UTF-16"); |
79 set_prepopulate_id(&template_url, 10); | 82 set_prepopulate_id(&template_url, 10); |
80 set_logo_id(&template_url, 1000); | 83 set_logo_id(&template_url, 1000); |
81 template_url.set_created_by_policy(true); | 84 template_url.set_created_by_policy(true); |
82 template_url.SetInstantURL("http://instant/", 0, 0); | 85 template_url.SetInstantURL("http://instant/", 0, 0); |
83 SetID(1, &template_url); | 86 SetID(1, &template_url); |
(...skipping 12 matching lines...) Expand all Loading... |
96 | 99 |
97 EXPECT_FALSE(restored_url->autogenerate_keyword()); | 100 EXPECT_FALSE(restored_url->autogenerate_keyword()); |
98 | 101 |
99 EXPECT_TRUE(favicon_url == restored_url->GetFaviconURL()); | 102 EXPECT_TRUE(favicon_url == restored_url->GetFaviconURL()); |
100 | 103 |
101 EXPECT_TRUE(restored_url->safe_for_autoreplace()); | 104 EXPECT_TRUE(restored_url->safe_for_autoreplace()); |
102 | 105 |
103 // The database stores time only at the resolution of a second. | 106 // The database stores time only at the resolution of a second. |
104 EXPECT_EQ(created_time.ToTimeT(), restored_url->date_created().ToTimeT()); | 107 EXPECT_EQ(created_time.ToTimeT(), restored_url->date_created().ToTimeT()); |
105 | 108 |
| 109 EXPECT_EQ(last_modified_time.ToTimeT(), |
| 110 restored_url->last_modified().ToTimeT()); |
| 111 |
106 EXPECT_TRUE(restored_url->show_in_default_list()); | 112 EXPECT_TRUE(restored_url->show_in_default_list()); |
107 | 113 |
108 EXPECT_EQ(GetID(&template_url), GetID(restored_url)); | 114 EXPECT_EQ(GetID(&template_url), GetID(restored_url)); |
109 | 115 |
110 EXPECT_TRUE(originating_url == restored_url->originating_url()); | 116 EXPECT_TRUE(originating_url == restored_url->originating_url()); |
111 | 117 |
112 EXPECT_EQ(32, restored_url->usage_count()); | 118 EXPECT_EQ(32, restored_url->usage_count()); |
113 | 119 |
114 ASSERT_EQ(2U, restored_url->input_encodings().size()); | 120 ASSERT_EQ(2U, restored_url->input_encodings().size()); |
115 EXPECT_EQ("UTF-8", restored_url->input_encodings()[0]); | 121 EXPECT_EQ("UTF-8", restored_url->input_encodings()[0]); |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 EXPECT_EQ(1U, template_urls.size()); | 244 EXPECT_EQ(1U, template_urls.size()); |
239 const TemplateURL* restored_url = template_urls.front(); | 245 const TemplateURL* restored_url = template_urls.front(); |
240 | 246 |
241 EXPECT_EQ(template_url.short_name(), restored_url->short_name()); | 247 EXPECT_EQ(template_url.short_name(), restored_url->short_name()); |
242 EXPECT_EQ(template_url.keyword(), restored_url->keyword()); | 248 EXPECT_EQ(template_url.keyword(), restored_url->keyword()); |
243 EXPECT_TRUE(!restored_url->GetFaviconURL().is_valid()); | 249 EXPECT_TRUE(!restored_url->GetFaviconURL().is_valid()); |
244 EXPECT_TRUE(restored_url->safe_for_autoreplace()); | 250 EXPECT_TRUE(restored_url->safe_for_autoreplace()); |
245 EXPECT_EQ(GetID(&template_url), GetID(restored_url)); | 251 EXPECT_EQ(GetID(&template_url), GetID(restored_url)); |
246 delete restored_url; | 252 delete restored_url; |
247 } | 253 } |
OLD | NEW |