OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/shortcuts_database.h" | 5 #include "chrome/browser/autocomplete/shortcuts_database.h" |
6 | 6 |
7 #include "base/files/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.h" |
8 #include "base/format_macros.h" | 8 #include "base/format_macros.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
13 #include "chrome/common/chrome_constants.h" | 13 #include "chrome/common/chrome_constants.h" |
14 #include "chrome/common/chrome_paths.h" | 14 #include "chrome/common/chrome_paths.h" |
15 #include "chrome/test/base/testing_profile.h" | 15 #include "chrome/test/base/testing_profile.h" |
16 #include "components/omnibox/autocomplete_match_type.h" | 16 #include "components/omnibox/autocomplete_match_type.h" |
| 17 #include "content/public/test/test_browser_thread_bundle.h" |
17 #include "sql/statement.h" | 18 #include "sql/statement.h" |
18 #include "sql/test/test_helpers.h" | 19 #include "sql/test/test_helpers.h" |
19 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
20 #include "ui/base/page_transition_types.h" | 21 #include "ui/base/page_transition_types.h" |
21 | 22 |
22 using base::ASCIIToUTF16; | 23 using base::ASCIIToUTF16; |
23 | 24 |
24 // Helpers -------------------------------------------------------------------- | 25 // Helpers -------------------------------------------------------------------- |
25 | 26 |
26 namespace { | 27 namespace { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 void TearDown() override; | 81 void TearDown() override; |
81 | 82 |
82 void ClearDB(); | 83 void ClearDB(); |
83 size_t CountRecords() const; | 84 size_t CountRecords() const; |
84 | 85 |
85 ShortcutsDatabase::Shortcut ShortcutFromTestInfo( | 86 ShortcutsDatabase::Shortcut ShortcutFromTestInfo( |
86 const ShortcutsDatabaseTestInfo& info); | 87 const ShortcutsDatabaseTestInfo& info); |
87 | 88 |
88 void AddAll(); | 89 void AddAll(); |
89 | 90 |
| 91 content::TestBrowserThreadBundle thread_bundle_; |
90 scoped_ptr<TestingProfile> profile_; | 92 scoped_ptr<TestingProfile> profile_; |
91 scoped_refptr<ShortcutsDatabase> db_; | 93 scoped_refptr<ShortcutsDatabase> db_; |
92 }; | 94 }; |
93 | 95 |
94 void ShortcutsDatabaseTest::SetUp() { | 96 void ShortcutsDatabaseTest::SetUp() { |
95 profile_.reset(new TestingProfile()); | 97 profile_.reset(new TestingProfile()); |
96 db_ = new ShortcutsDatabase( | 98 db_ = new ShortcutsDatabase( |
97 profile_->GetPath().Append(chrome::kShortcutsDatabaseName)); | 99 profile_->GetPath().Append(chrome::kShortcutsDatabaseName)); |
98 ASSERT_TRUE(db_->Init()); | 100 ASSERT_TRUE(db_->Init()); |
99 ClearDB(); | 101 ClearDB(); |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 sql::Statement statement(connection.GetUniqueStatement( | 292 sql::Statement statement(connection.GetUniqueStatement( |
291 "SELECT count(1) FROM omni_box_shortcuts WHERE type in (9, 10, 11, 12)")); | 293 "SELECT count(1) FROM omni_box_shortcuts WHERE type in (9, 10, 11, 12)")); |
292 ASSERT_TRUE(statement.is_valid()); | 294 ASSERT_TRUE(statement.is_valid()); |
293 while (statement.Step()) | 295 while (statement.Step()) |
294 EXPECT_EQ(0, statement.ColumnInt(0)); | 296 EXPECT_EQ(0, statement.ColumnInt(0)); |
295 EXPECT_TRUE(statement.Succeeded()); | 297 EXPECT_TRUE(statement.Succeeded()); |
296 #if !defined(OS_WIN) | 298 #if !defined(OS_WIN) |
297 EXPECT_TRUE(temp_dir.Delete()); | 299 EXPECT_TRUE(temp_dir.Delete()); |
298 #endif | 300 #endif |
299 } | 301 } |
OLD | NEW |