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 "base/file_path.h" | 5 #include "base/file_path.h" |
6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
| 7 #include "base/files/scoped_temp_dir.h" |
7 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
8 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
9 #include "base/path_service.h" | 10 #include "base/path_service.h" |
10 #include "base/scoped_temp_dir.h" | |
11 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
12 #include "chrome/browser/extensions/app_notification.h" | 12 #include "chrome/browser/extensions/app_notification.h" |
13 #include "chrome/browser/extensions/app_notification_storage.h" | 13 #include "chrome/browser/extensions/app_notification_storage.h" |
14 #include "chrome/browser/extensions/app_notification_test_util.h" | 14 #include "chrome/browser/extensions/app_notification_test_util.h" |
15 #include "chrome/common/extensions/extension_test_util.h" | 15 #include "chrome/common/extensions/extension_test_util.h" |
16 #include "content/public/test/test_browser_thread.h" | 16 #include "content/public/test/test_browser_thread.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
18 | 18 |
19 using content::BrowserThread; | 19 using content::BrowserThread; |
20 | 20 |
(...skipping 18 matching lines...) Expand all Loading... |
39 // Returns whether the database file(s) exist on disk yet. | 39 // Returns whether the database file(s) exist on disk yet. |
40 bool DatabaseExistsOnDisk() { | 40 bool DatabaseExistsOnDisk() { |
41 if (!storage_.get()) | 41 if (!storage_.get()) |
42 return false; | 42 return false; |
43 | 43 |
44 return file_util::PathExists(storage_path_); | 44 return file_util::PathExists(storage_path_); |
45 } | 45 } |
46 | 46 |
47 MessageLoop message_loop_; | 47 MessageLoop message_loop_; |
48 content::TestBrowserThread file_thread_; | 48 content::TestBrowserThread file_thread_; |
49 ScopedTempDir dir_; | 49 base::ScopedTempDir dir_; |
50 FilePath storage_path_; | 50 FilePath storage_path_; |
51 scoped_ptr<AppNotificationStorage> storage_; | 51 scoped_ptr<AppNotificationStorage> storage_; |
52 }; | 52 }; |
53 | 53 |
54 // Tests simple operations. | 54 // Tests simple operations. |
55 TEST_F(AppNotificationStorageTest, Basics) { | 55 TEST_F(AppNotificationStorageTest, Basics) { |
56 std::set<std::string> tmp_ids; | 56 std::set<std::string> tmp_ids; |
57 AppNotificationList tmp_list; | 57 AppNotificationList tmp_list; |
58 std::string id1 = extension_test_util::MakeId("1"); | 58 std::string id1 = extension_test_util::MakeId("1"); |
59 | 59 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 | 134 |
135 // Put list1 in, then replace with list2 and verify we get list2 back. | 135 // Put list1 in, then replace with list2 and verify we get list2 back. |
136 EXPECT_TRUE(storage_->Set(id, list1)); | 136 EXPECT_TRUE(storage_->Set(id, list1)); |
137 EXPECT_TRUE(storage_->Set(id, list2)); | 137 EXPECT_TRUE(storage_->Set(id, list2)); |
138 AppNotificationList tmp_list; | 138 AppNotificationList tmp_list; |
139 EXPECT_TRUE(storage_->Get(id, &tmp_list)); | 139 EXPECT_TRUE(storage_->Get(id, &tmp_list)); |
140 util::ExpectListsEqual(list2, tmp_list); | 140 util::ExpectListsEqual(list2, tmp_list); |
141 } | 141 } |
142 | 142 |
143 } // namespace extensions | 143 } // namespace extensions |
OLD | NEW |