Chromium Code Reviews| Index: content/browser/media_gallery/media_gallery_database_unittest.cc |
| diff --git a/content/browser/media_gallery/media_gallery_database_unittest.cc b/content/browser/media_gallery/media_gallery_database_unittest.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..db03822b4bad9638b51e204a41ecb628d2dbda66 |
| --- /dev/null |
| +++ b/content/browser/media_gallery/media_gallery_database_unittest.cc |
| @@ -0,0 +1,64 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "base/file_path.h" |
| +#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.
|
| +#include "base/path_service.h" |
| +#include "base/scoped_temp_dir.h" |
| +#include "base/string_util.h" |
| +#include "content/browser/media_gallery/media_gallery_database.h" |
| +#include "sql/connection.h" |
| +#include "testing/gtest/include/gtest/gtest.h" |
| + |
| +namespace media_gallery { |
| + |
| +class MediaGalleryDatabaseTest : public testing::Test, |
| + public MediaGalleryDatabase { |
| + public: |
| + MediaGalleryDatabaseTest() { } |
| + |
| + protected: |
| + virtual sql::Connection& GetDB() { |
| + return db_; |
| + } |
| + |
| + private: |
| + // Test setup. |
| + void SetUp() { |
| + ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| + FilePath db_file = temp_dir_.path().AppendASCII("MediaGalleryTest.db"); |
| + |
| + 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.
|
| + |
| + // Initialize the tables for this test. |
| + EXPECT_EQ(sql::INIT_OK, InitInternal(&db_)); |
| + } |
| + |
| + void TearDown() { |
| + db_.Close(); |
| + } |
| + |
| + ScopedTempDir temp_dir_; |
| + sql::Connection db_; |
| +}; |
| + |
| +TEST_F(MediaGalleryDatabaseTest, Init) { |
| + 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.
|
| +} |
| + |
| +TEST_F(MediaGalleryDatabaseTest, AddCollection) { |
| + CollectionRow row1(FilePath(FILE_PATH_LITERAL("path1")), |
| + base::Time::FromDoubleT(12345), |
| + 123, |
| + false); |
| + COLLECTIONID rowid = CreateCollectionRow(&row1); |
| + 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.
|
| + ASSERT_EQ(rowid, row1.GetId()); |
| + |
| + CollectionRow row2; |
| + ASSERT_TRUE(GetCollectionRow(rowid, &row2)); |
| + ASSERT_EQ(row1, row2); |
| +} |
| + |
| +} // namespace media_gallery |