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/string_number_conversions.h" | 5 #include "base/string_number_conversions.h" |
6 #include "base/utf_string_conversions.h" | 6 #include "base/utf_string_conversions.h" |
7 #include "content/public/browser/browser_context.h" | 7 #include "content/public/browser/browser_context.h" |
8 #include "content/public/browser/download_manager.h" | 8 #include "content/public/browser/download_manager.h" |
9 #include "content/public/browser/notification_service.h" | 9 #include "content/public/browser/notification_service.h" |
10 #include "content/public/browser/notification_types.h" | 10 #include "content/public/browser/notification_types.h" |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 UpdateRecord(shell(), 1, "1000"); | 95 UpdateRecord(shell(), 1, "1000"); |
96 CompareRecords(shell(), "0, 1000, 2"); | 96 CompareRecords(shell(), "0, 1000, 2"); |
97 } | 97 } |
98 | 98 |
99 // Delete records in the database. | 99 // Delete records in the database. |
100 IN_PROC_BROWSER_TEST_F(DatabaseTest, DeleteRecord) { | 100 IN_PROC_BROWSER_TEST_F(DatabaseTest, DeleteRecord) { |
101 Navigate(shell()); | 101 Navigate(shell()); |
102 CreateTable(shell()); | 102 CreateTable(shell()); |
103 InsertRecord(shell(), "text"); | 103 InsertRecord(shell(), "text"); |
104 DeleteRecord(shell(), 0); | 104 DeleteRecord(shell(), 0); |
105 CompareRecords(shell(), ""); | 105 CompareRecords(shell(), std::string()); |
106 | 106 |
107 InsertRecord(shell(), "0"); | 107 InsertRecord(shell(), "0"); |
108 InsertRecord(shell(), "1"); | 108 InsertRecord(shell(), "1"); |
109 InsertRecord(shell(), "2"); | 109 InsertRecord(shell(), "2"); |
110 DeleteRecord(shell(), 1); | 110 DeleteRecord(shell(), 1); |
111 CompareRecords(shell(), "0, 2"); | 111 CompareRecords(shell(), "0, 2"); |
112 } | 112 } |
113 | 113 |
114 // Attempts to delete a nonexistent row in the table. | 114 // Attempts to delete a nonexistent row in the table. |
115 IN_PROC_BROWSER_TEST_F(DatabaseTest, DeleteNonexistentRow) { | 115 IN_PROC_BROWSER_TEST_F(DatabaseTest, DeleteNonexistentRow) { |
(...skipping 28 matching lines...) Expand all Loading... |
144 UpdateRecord(shell(), i, item); | 144 UpdateRecord(shell(), i, item); |
145 if (!expected.empty()) | 145 if (!expected.empty()) |
146 expected += ", "; | 146 expected += ", "; |
147 expected += item; | 147 expected += item; |
148 } | 148 } |
149 CompareRecords(shell(), expected); | 149 CompareRecords(shell(), expected); |
150 | 150 |
151 for (int i = 0; i < 10; ++i) | 151 for (int i = 0; i < 10; ++i) |
152 DeleteRecord(shell(), 0); | 152 DeleteRecord(shell(), 0); |
153 | 153 |
154 CompareRecords(shell(), ""); | 154 CompareRecords(shell(), std::string()); |
155 | 155 |
156 RunScriptAndCheckResult( | 156 RunScriptAndCheckResult( |
157 shell(), "deleteRecord(1)", "could not find row with index: 1"); | 157 shell(), "deleteRecord(1)", "could not find row with index: 1"); |
158 | 158 |
159 CompareRecords(shell(), ""); | 159 CompareRecords(shell(), std::string()); |
160 } | 160 } |
161 | 161 |
162 // Create records in the database and verify they persist after reload. | 162 // Create records in the database and verify they persist after reload. |
163 IN_PROC_BROWSER_TEST_F(DatabaseTest, ReloadPage) { | 163 IN_PROC_BROWSER_TEST_F(DatabaseTest, ReloadPage) { |
164 Navigate(shell()); | 164 Navigate(shell()); |
165 CreateTable(shell()); | 165 CreateTable(shell()); |
166 InsertRecord(shell(), "text"); | 166 InsertRecord(shell(), "text"); |
167 | 167 |
168 WindowedNotificationObserver load_stop_observer( | 168 WindowedNotificationObserver load_stop_observer( |
169 NOTIFICATION_LOAD_STOP, | 169 NOTIFICATION_LOAD_STOP, |
170 NotificationService::AllSources()); | 170 NotificationService::AllSources()); |
171 shell()->Reload(); | 171 shell()->Reload(); |
172 load_stop_observer.Wait(); | 172 load_stop_observer.Wait(); |
173 | 173 |
174 CompareRecords(shell(), "text"); | 174 CompareRecords(shell(), "text"); |
175 } | 175 } |
176 | 176 |
177 // Attempt to read a database created in a regular browser from an off the | 177 // Attempt to read a database created in a regular browser from an off the |
178 // record browser. | 178 // record browser. |
179 IN_PROC_BROWSER_TEST_F(DatabaseTest, OffTheRecordCannotReadRegularDatabase) { | 179 IN_PROC_BROWSER_TEST_F(DatabaseTest, OffTheRecordCannotReadRegularDatabase) { |
180 Navigate(shell()); | 180 Navigate(shell()); |
181 CreateTable(shell()); | 181 CreateTable(shell()); |
182 InsertRecord(shell(), "text"); | 182 InsertRecord(shell(), "text"); |
183 | 183 |
184 Shell* otr = CreateOffTheRecordBrowser(); | 184 Shell* otr = CreateOffTheRecordBrowser(); |
185 Navigate(otr); | 185 Navigate(otr); |
186 ASSERT_FALSE(HasTable(otr)); | 186 ASSERT_FALSE(HasTable(otr)); |
187 | 187 |
188 CreateTable(otr); | 188 CreateTable(otr); |
189 CompareRecords(otr, ""); | 189 CompareRecords(otr, std::string()); |
190 } | 190 } |
191 | 191 |
192 // Attempt to read a database created in an off the record browser from a | 192 // Attempt to read a database created in an off the record browser from a |
193 // regular browser. | 193 // regular browser. |
194 IN_PROC_BROWSER_TEST_F(DatabaseTest, RegularCannotReadOffTheRecordDatabase) { | 194 IN_PROC_BROWSER_TEST_F(DatabaseTest, RegularCannotReadOffTheRecordDatabase) { |
195 Shell* otr = CreateOffTheRecordBrowser(); | 195 Shell* otr = CreateOffTheRecordBrowser(); |
196 Navigate(otr); | 196 Navigate(otr); |
197 CreateTable(otr); | 197 CreateTable(otr); |
198 InsertRecord(otr, "text"); | 198 InsertRecord(otr, "text"); |
199 | 199 |
200 Navigate(shell()); | 200 Navigate(shell()); |
201 ASSERT_FALSE(HasTable(shell())); | 201 ASSERT_FALSE(HasTable(shell())); |
202 CreateTable(shell()); | 202 CreateTable(shell()); |
203 CompareRecords(shell(), ""); | 203 CompareRecords(shell(), std::string()); |
204 } | 204 } |
205 | 205 |
206 // Verify DB changes within first window are present in the second window. | 206 // Verify DB changes within first window are present in the second window. |
207 IN_PROC_BROWSER_TEST_F(DatabaseTest, ModificationPersistInSecondTab) { | 207 IN_PROC_BROWSER_TEST_F(DatabaseTest, ModificationPersistInSecondTab) { |
208 Navigate(shell()); | 208 Navigate(shell()); |
209 CreateTable(shell()); | 209 CreateTable(shell()); |
210 InsertRecord(shell(), "text"); | 210 InsertRecord(shell(), "text"); |
211 | 211 |
212 Shell* shell2 = CreateBrowser(); | 212 Shell* shell2 = CreateBrowser(); |
213 Navigate(shell2); | 213 Navigate(shell2); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 Navigate(otr1); | 261 Navigate(otr1); |
262 CreateTable(otr1); | 262 CreateTable(otr1); |
263 InsertRecord(otr1, "text"); | 263 InsertRecord(otr1, "text"); |
264 | 264 |
265 Shell* otr2 = CreateOffTheRecordBrowser(); | 265 Shell* otr2 = CreateOffTheRecordBrowser(); |
266 Navigate(otr2); | 266 Navigate(otr2); |
267 CompareRecords(otr2, "text"); | 267 CompareRecords(otr2, "text"); |
268 } | 268 } |
269 | 269 |
270 } // namespace content | 270 } // namespace content |
OLD | NEW |