Chromium Code Reviews| OLD | NEW |
|---|---|
| (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" | |
|
Lei Zhang
2012/03/05 23:38:36
Not used, remove. Same for path_service.h and stri
tpayne
2012/03/06 01:52:37
Done.
| |
| 7 #include "base/path_service.h" | |
| 8 #include "base/scoped_temp_dir.h" | |
| 9 #include "base/string_util.h" | |
| 10 #include "content/browser/media_gallery/media_gallery_database.h" | |
| 11 #include "sql/connection.h" | |
| 12 #include "testing/gtest/include/gtest/gtest.h" | |
| 13 | |
| 14 namespace media_gallery { | |
| 15 | |
| 16 class MediaGalleryDatabaseTest : public testing::Test, | |
| 17 public MediaGalleryDatabase { | |
| 18 public: | |
| 19 MediaGalleryDatabaseTest() { } | |
| 20 | |
| 21 protected: | |
| 22 virtual sql::Connection& GetDB() { | |
| 23 return db_; | |
| 24 } | |
| 25 | |
| 26 private: | |
| 27 // Test setup. | |
| 28 void SetUp() { | |
| 29 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | |
| 30 FilePath db_file = temp_dir_.path().AppendASCII("MediaGalleryTest.db"); | |
| 31 | |
| 32 EXPECT_TRUE(db_.Open(db_file)); | |
|
Lei Zhang
2012/03/05 23:38:36
I would change these to be ASSERT_FOO. If the set
tpayne
2012/03/06 01:52:37
Done.
| |
| 33 | |
| 34 // Initialize the tables for this test. | |
| 35 EXPECT_EQ(sql::INIT_OK, InitInternal(&db_)); | |
| 36 } | |
| 37 | |
| 38 void TearDown() { | |
| 39 db_.Close(); | |
| 40 } | |
| 41 | |
| 42 ScopedTempDir temp_dir_; | |
| 43 sql::Connection db_; | |
| 44 }; | |
| 45 | |
| 46 TEST_F(MediaGalleryDatabaseTest, Init) { | |
| 47 EXPECT_TRUE(GetDB().DoesTableExist("collections")); | |
|
Lei Zhang
2012/03/05 23:38:36
Maybe this should be in the header file so you can
tpayne
2012/03/06 01:52:37
Why would the implementation want this?
Lei Zhang
2012/03/06 01:57:46
It's used on content/browser/media_gallery/media_g
tpayne
2012/03/06 02:02:46
Done. I don't think it helps much, though.
| |
| 48 } | |
| 49 | |
| 50 TEST_F(MediaGalleryDatabaseTest, AddCollection) { | |
| 51 CollectionRow row1(FilePath(FILE_PATH_LITERAL("path1")), | |
| 52 base::Time::FromDoubleT(12345), | |
| 53 123, | |
| 54 false); | |
| 55 COLLECTIONID rowid = CreateCollectionRow(&row1); | |
| 56 ASSERT_TRUE(rowid); | |
|
Lei Zhang
2012/03/05 23:38:36
These can probably be EXPECT_FOO.
tpayne
2012/03/06 01:52:37
Done.
| |
| 57 ASSERT_EQ(rowid, row1.GetId()); | |
| 58 | |
| 59 CollectionRow row2; | |
| 60 ASSERT_TRUE(GetCollectionRow(rowid, &row2)); | |
| 61 ASSERT_EQ(row1, row2); | |
| 62 } | |
| 63 | |
| 64 } // namespace media_gallery | |
| OLD | NEW |