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

Side by Side Diff: content/browser/media_gallery/media_gallery_database_unittest.cc

Issue 9567035: Added MediaGalleryDatabase (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Fix windows compile 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 | Annotate | Revision Log
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_util.h"
Lei Zhang 2012/03/07 01:41:42 nit: you only need file_path.h.
tpayne 2012/03/07 18:04:03 Done.
6 #include "base/scoped_temp_dir.h"
7 #include "content/browser/media_gallery/media_gallery_database.h"
8 #include "content/browser/media_gallery/media_gallery_types.h"
9 #include "sql/connection.h"
10 #include "testing/gtest/include/gtest/gtest.h"
11
12 namespace media_gallery {
13
14 class MediaGalleryDatabaseTest : public testing::Test,
15 public MediaGalleryDatabase {
16 public:
17 MediaGalleryDatabaseTest() { }
18
19 protected:
20 virtual sql::Connection& GetDB() {
21 return db_;
22 }
23
24 private:
25 // Test setup.
26 void SetUp() {
27 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
28 FilePath db_file = temp_dir_.path().AppendASCII("MediaGalleryTest.db");
29
30 ASSERT_TRUE(db_.Open(db_file));
31
32 // Initialize the tables for this test.
33 ASSERT_EQ(sql::INIT_OK, InitInternal(&db_));
34 }
35
36 void TearDown() {
37 db_.Close();
38 }
39
40 ScopedTempDir temp_dir_;
41 sql::Connection db_;
42 };
43
44 TEST_F(MediaGalleryDatabaseTest, Init) {
45 EXPECT_TRUE(DoesCollectionsTableExist(&GetDB()));
46 }
47
48 TEST_F(MediaGalleryDatabaseTest, AddCollection) {
49 CollectionRow row1(FilePath(FILE_PATH_LITERAL("path1")),
50 base::Time::FromDoubleT(12345),
51 123,
52 false);
53 CollectionId rowid = CreateCollectionRow(&row1);
54 EXPECT_TRUE(rowid);
Lei Zhang 2012/03/07 01:41:42 Do you need this when you have the test on the nex
tpayne 2012/03/07 18:04:03 Done.
Lei Zhang 2012/03/07 21:24:37 You didn't do anything here.
tpayne 2012/03/07 21:34:54 Done.
55 EXPECT_EQ(rowid, row1.id);
56
57 CollectionRow row2;
58 EXPECT_TRUE(GetCollectionRow(rowid, &row2));
59 EXPECT_TRUE(row1 == row2);
Lei Zhang 2012/03/07 01:41:42 EXPECT_EQ(row1, row2);
tpayne 2012/03/07 18:04:03 This requires defining operator<< for CollectionRo
60 }
61
62 } // namespace media_gallery
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698