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

Side by Side Diff: chrome/browser/history/android/android_cache_database_unittest.cc

Issue 9549031: The implementation of AndroidCacheDatabase. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: a small change of a method parameter Created 8 years, 9 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "base/file_path.h"
6 #include "base/file_util.h"
7 #include "base/scoped_temp_dir.h"
8 #include "chrome/browser/history/android/android_provider_backend.h"
9 #include "chrome/browser/history/history_database.h"
10 #include "chrome/test/base/testing_profile.h"
11 #include "testing/gtest/include/gtest/gtest.h"
12
13 namespace history {
14
15 class SimpleAndroidCacheDatabase : public AndroidCacheDatabase {
16 public:
17 explicit SimpleAndroidCacheDatabase(sql::Connection* connection)
18 :db_(connection) {
19 }
20
21 protected:
22 sql::Connection& GetDB() {
23 return *db_;
24 }
25
26 private:
27 sql::Connection* db_;
28 };
29
30 class AndroidCacheDatabaseTest : public testing::Test {
31 public:
32 AndroidCacheDatabaseTest() {
33 }
34 ~AndroidCacheDatabaseTest() {
35 }
36
37 protected:
38 virtual void SetUp() {
39 // Get a temporary directory for the test DB files.
40 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
41 main_db_name_ = temp_dir_.path().AppendASCII("history.db");
42 android_cache_db_name_ = temp_dir_.path().AppendASCII(
43 "TestAndroidCache.db");
44 }
45
46 ScopedTempDir temp_dir_;
47 FilePath android_cache_db_name_;
48 FilePath main_db_name_;
49 };
50
51 TEST_F(AndroidCacheDatabaseTest, InitAndroidCacheDatabase) {
52 {
53 sql::Connection connection;
54 ASSERT_TRUE(connection.Open(main_db_name_));
55 SimpleAndroidCacheDatabase android_cache_db(&connection);
56 EXPECT_EQ(sql::INIT_OK,
57 android_cache_db.InitAndroidCacheDatabase(android_cache_db_name_));
58 // Try to run a sql against the table to verify it exists.
59 EXPECT_TRUE(connection.Execute(
60 "DELETE FROM android_cache_db.bookmark_cache"));
61 connection.Close();
62 }
63 // The database file should be deleted.
64 EXPECT_FALSE(file_util::PathExists(android_cache_db_name_));
65 }
66
67 } // namespace history
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698