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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
9 #include "chrome/browser/media_gallery/media_gallery_database.h" | 9 #include "chrome/browser/media_gallery/media_gallery_database.h" |
10 #include "chrome/browser/media_gallery/media_gallery_database_types.h" | 10 #include "chrome/browser/media_gallery/media_gallery_database_types.h" |
11 #include "sql/connection.h" | 11 #include "sql/connection.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
13 | 13 |
14 namespace chrome { | 14 namespace chrome { |
15 | 15 |
16 class MediaGalleryDatabaseTest : public testing::Test, | 16 class MediaGalleryDatabaseTest : public testing::Test, |
17 public MediaGalleryDatabase { | 17 public MediaGalleryDatabase { |
18 public: | 18 public: |
19 MediaGalleryDatabaseTest() { } | 19 MediaGalleryDatabaseTest() { } |
20 | 20 |
21 protected: | 21 protected: |
22 virtual sql::Connection& GetDB() { | 22 virtual sql::Connection& GetDB() OVERRIDE { |
23 return db_; | 23 return db_; |
24 } | 24 } |
25 | 25 |
26 private: | 26 private: |
27 // Test setup. | 27 // Test setup. |
28 void SetUp() { | 28 virtual void SetUp() { |
29 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 29 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
30 base::FilePath db_file = | 30 base::FilePath db_file = |
31 temp_dir_.path().AppendASCII("MediaGalleryTest.db"); | 31 temp_dir_.path().AppendASCII("MediaGalleryTest.db"); |
32 | 32 |
33 ASSERT_TRUE(db_.Open(db_file)); | 33 ASSERT_TRUE(db_.Open(db_file)); |
34 | 34 |
35 // Initialize the tables for this test. | 35 // Initialize the tables for this test. |
36 ASSERT_EQ(sql::INIT_OK, InitInternal(&db_)); | 36 ASSERT_EQ(sql::INIT_OK, InitInternal(&db_)); |
37 } | 37 } |
38 | 38 |
39 void TearDown() { | 39 virtual void TearDown() { |
40 db_.Close(); | 40 db_.Close(); |
41 } | 41 } |
42 | 42 |
43 base::ScopedTempDir temp_dir_; | 43 base::ScopedTempDir temp_dir_; |
44 sql::Connection db_; | 44 sql::Connection db_; |
45 }; | 45 }; |
46 | 46 |
47 TEST_F(MediaGalleryDatabaseTest, Init) { | 47 TEST_F(MediaGalleryDatabaseTest, Init) { |
48 EXPECT_TRUE(DoesCollectionsTableExist(&GetDB())); | 48 EXPECT_TRUE(DoesCollectionsTableExist(&GetDB())); |
49 } | 49 } |
(...skipping 20 matching lines...) Expand all Loading... |
70 false); | 70 false); |
71 CollectionId rowid = CreateCollectionRow(&row1); | 71 CollectionId rowid = CreateCollectionRow(&row1); |
72 EXPECT_EQ(rowid, row1.id); | 72 EXPECT_EQ(rowid, row1.id); |
73 | 73 |
74 CollectionRow row2; | 74 CollectionRow row2; |
75 EXPECT_TRUE(GetCollectionRow(rowid, &row2)); | 75 EXPECT_TRUE(GetCollectionRow(rowid, &row2)); |
76 EXPECT_EQ(FILE_PATH_LITERAL("path1/path2"), row2.path.value()); | 76 EXPECT_EQ(FILE_PATH_LITERAL("path1/path2"), row2.path.value()); |
77 } | 77 } |
78 | 78 |
79 } // namespace chrome | 79 } // namespace chrome |
OLD | NEW |