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

Side by Side Diff: components/omnibox/browser/shortcuts_database_unittest.cc

Issue 2130353002: Prevents the shortcuts DB from going out of scope before unittests run. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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
« no previous file with comments | « no previous file | 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) 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 "components/omnibox/browser/shortcuts_database.h" 5 #include "components/omnibox/browser/shortcuts_database.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/files/scoped_temp_dir.h" 9 #include "base/files/scoped_temp_dir.h"
10 #include "base/format_macros.h" 10 #include "base/format_macros.h"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 void TearDown() override; 89 void TearDown() override;
90 90
91 void ClearDB(); 91 void ClearDB();
92 size_t CountRecords() const; 92 size_t CountRecords() const;
93 93
94 ShortcutsDatabase::Shortcut ShortcutFromTestInfo( 94 ShortcutsDatabase::Shortcut ShortcutFromTestInfo(
95 const ShortcutsDatabaseTestInfo& info); 95 const ShortcutsDatabaseTestInfo& info);
96 96
97 void AddAll(); 97 void AddAll();
98 98
99 base::ScopedTempDir temp_dir_;
99 scoped_refptr<ShortcutsDatabase> db_; 100 scoped_refptr<ShortcutsDatabase> db_;
100 }; 101 };
101 102
102 void ShortcutsDatabaseTest::SetUp() { 103 void ShortcutsDatabaseTest::SetUp() {
103 base::ScopedTempDir temp_dir; 104 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
104 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); 105 base::FilePath db_path(temp_dir_.path().Append(kShortcutsDatabaseName));
105 base::FilePath db_path(temp_dir.path().Append(kShortcutsDatabaseName));
106 db_ = new ShortcutsDatabase(db_path); 106 db_ = new ShortcutsDatabase(db_path);
107 ASSERT_TRUE(db_->Init()); 107 ASSERT_TRUE(db_->Init());
108 ClearDB(); 108 ClearDB();
109 } 109 }
110 110
111 void ShortcutsDatabaseTest::TearDown() { 111 void ShortcutsDatabaseTest::TearDown() {
112 db_ = NULL; 112 db_ = NULL;
113 } 113 }
114 114
115 void ShortcutsDatabaseTest::ClearDB() { 115 void ShortcutsDatabaseTest::ClearDB() {
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 // recovered. 363 // recovered.
364 { 364 {
365 sql::Connection connection; 365 sql::Connection connection;
366 ASSERT_TRUE(connection.Open(db_path)); 366 ASSERT_TRUE(connection.Open(db_path));
367 sql::Statement statement(connection.GetUniqueStatement(kCountSql)); 367 sql::Statement statement(connection.GetUniqueStatement(kCountSql));
368 ASSERT_TRUE(statement.is_valid()); 368 ASSERT_TRUE(statement.is_valid());
369 ASSERT_TRUE(statement.Step()); 369 ASSERT_TRUE(statement.Step());
370 EXPECT_EQ(row_count, statement.ColumnInt(0)); 370 EXPECT_EQ(row_count, statement.ColumnInt(0));
371 } 371 }
372 } 372 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698