OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/file_util.h" | 5 #include "base/file_util.h" |
6 #include "base/path_service.h" | 6 #include "base/path_service.h" |
| 7 #include "base/scoped_temp_dir.h" |
7 #include "base/string_number_conversions.h" | 8 #include "base/string_number_conversions.h" |
8 #include "base/time.h" | 9 #include "base/time.h" |
9 #include "chrome/browser/webdata/web_apps_table.h" | 10 #include "chrome/browser/webdata/web_apps_table.h" |
10 #include "chrome/browser/webdata/web_database.h" | 11 #include "chrome/browser/webdata/web_database.h" |
11 #include "chrome/common/chrome_paths.h" | 12 #include "chrome/common/chrome_paths.h" |
12 #include "googleurl/src/gurl.h" | 13 #include "googleurl/src/gurl.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
14 #include "third_party/skia/include/core/SkBitmap.h" | 15 #include "third_party/skia/include/core/SkBitmap.h" |
15 | 16 |
16 using base::Time; | 17 using base::Time; |
17 | 18 |
18 class WebAppsTableTest : public testing::Test { | 19 class WebAppsTableTest : public testing::Test { |
19 public: | 20 public: |
20 WebAppsTableTest() {} | 21 WebAppsTableTest() {} |
21 virtual ~WebAppsTableTest() {} | 22 virtual ~WebAppsTableTest() {} |
22 | 23 |
23 protected: | 24 protected: |
24 virtual void SetUp() { | 25 virtual void SetUp() { |
25 PathService::Get(chrome::DIR_TEST_DATA, &file_); | 26 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
26 const std::string test_db = "TestWebDatabase" + | 27 file_ = temp_dir_.path().AppendASCII("TestWebDatabase"); |
27 base::Int64ToString(Time::Now().ToTimeT()) + | |
28 ".db"; | |
29 file_ = file_.AppendASCII(test_db); | |
30 file_util::Delete(file_, false); | |
31 } | |
32 | |
33 virtual void TearDown() { | |
34 file_util::Delete(file_, false); | |
35 } | 28 } |
36 | 29 |
37 FilePath file_; | 30 FilePath file_; |
| 31 ScopedTempDir temp_dir_; |
38 | 32 |
39 private: | 33 private: |
40 DISALLOW_COPY_AND_ASSIGN(WebAppsTableTest); | 34 DISALLOW_COPY_AND_ASSIGN(WebAppsTableTest); |
41 }; | 35 }; |
42 | 36 |
43 | 37 |
44 TEST_F(WebAppsTableTest, WebAppHasAllImages) { | 38 TEST_F(WebAppsTableTest, WebAppHasAllImages) { |
45 WebDatabase db; | 39 WebDatabase db; |
46 | 40 |
47 ASSERT_EQ(sql::INIT_OK, db.Init(file_)); | 41 ASSERT_EQ(sql::INIT_OK, db.Init(file_)); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 ASSERT_EQ(16, images[0].height()); | 119 ASSERT_EQ(16, images[0].height()); |
126 ASSERT_EQ(32, images[1].width()); | 120 ASSERT_EQ(32, images[1].width()); |
127 ASSERT_EQ(32, images[1].height()); | 121 ASSERT_EQ(32, images[1].height()); |
128 } else { | 122 } else { |
129 ASSERT_EQ(32, images[0].width()); | 123 ASSERT_EQ(32, images[0].width()); |
130 ASSERT_EQ(32, images[0].height()); | 124 ASSERT_EQ(32, images[0].height()); |
131 ASSERT_EQ(16, images[1].width()); | 125 ASSERT_EQ(16, images[1].width()); |
132 ASSERT_EQ(16, images[1].height()); | 126 ASSERT_EQ(16, images[1].height()); |
133 } | 127 } |
134 } | 128 } |
OLD | NEW |