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

Side by Side Diff: content/browser/database_browsertest.cc

Issue 2052633002: Extend the ToRenderFrameHost magic to FrameTreeNode* and Shell* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix induced script bug. Created 4 years, 6 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
OLDNEW
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/strings/string_number_conversions.h" 5 #include "base/strings/string_number_conversions.h"
6 #include "base/strings/utf_string_conversions.h" 6 #include "base/strings/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"
11 #include "content/public/browser/web_contents.h" 11 #include "content/public/browser/web_contents.h"
12 #include "content/public/test/browser_test_utils.h" 12 #include "content/public/test/browser_test_utils.h"
13 #include "content/public/test/content_browser_test.h" 13 #include "content/public/test/content_browser_test.h"
14 #include "content/public/test/content_browser_test_utils.h" 14 #include "content/public/test/content_browser_test_utils.h"
15 #include "content/public/test/test_utils.h" 15 #include "content/public/test/test_utils.h"
16 #include "content/shell/browser/shell.h" 16 #include "content/shell/browser/shell.h"
17 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
18 18
19 namespace content { 19 namespace content {
20 20
21 class DatabaseTest : public ContentBrowserTest { 21 class DatabaseTest : public ContentBrowserTest {
22 public: 22 public:
23 DatabaseTest() {} 23 DatabaseTest() {}
24 24
25 void RunScriptAndCheckResult(Shell* shell, 25 void RunScriptAndCheckResult(Shell* shell,
26 const std::string& script, 26 const std::string& script,
27 const std::string& result) { 27 const std::string& result) {
28 std::string data; 28 std::string data;
29 ASSERT_TRUE(ExecuteScriptAndExtractString( 29 ASSERT_TRUE(ExecuteScriptAndExtractString(shell, script, &data));
30 shell->web_contents(),
31 script,
32 &data));
33 ASSERT_EQ(data, result); 30 ASSERT_EQ(data, result);
34 } 31 }
35 32
36 void Navigate(Shell* shell) { 33 void Navigate(Shell* shell) {
37 NavigateToURL(shell, GetTestUrl("", "simple_database.html")); 34 NavigateToURL(shell, GetTestUrl("", "simple_database.html"));
38 } 35 }
39 36
40 void CreateTable(Shell* shell) { 37 void CreateTable(Shell* shell) {
41 RunScriptAndCheckResult(shell, "createTable()", "done"); 38 RunScriptAndCheckResult(shell, "createTable()", "done");
42 } 39 }
(...skipping 13 matching lines...) Expand all
56 RunScriptAndCheckResult( 53 RunScriptAndCheckResult(
57 shell, "deleteRecord(" + base::IntToString(index) + ")", "done"); 54 shell, "deleteRecord(" + base::IntToString(index) + ")", "done");
58 } 55 }
59 56
60 void CompareRecords(Shell* shell, const std::string& expected) { 57 void CompareRecords(Shell* shell, const std::string& expected) {
61 RunScriptAndCheckResult(shell, "getRecords()", expected); 58 RunScriptAndCheckResult(shell, "getRecords()", expected);
62 } 59 }
63 60
64 bool HasTable(Shell* shell) { 61 bool HasTable(Shell* shell) {
65 std::string data; 62 std::string data;
66 CHECK(ExecuteScriptAndExtractString( 63 CHECK(ExecuteScriptAndExtractString(shell, "getRecords()", &data));
67 shell->web_contents(),
68 "getRecords()",
69 &data));
70 return data != "getRecords error: [object SQLError]"; 64 return data != "getRecords error: [object SQLError]";
71 } 65 }
72 }; 66 };
73 67
74 // Insert records to the database. 68 // Insert records to the database.
75 IN_PROC_BROWSER_TEST_F(DatabaseTest, InsertRecord) { 69 IN_PROC_BROWSER_TEST_F(DatabaseTest, InsertRecord) {
76 Navigate(shell()); 70 Navigate(shell());
77 CreateTable(shell()); 71 CreateTable(shell());
78 InsertRecord(shell(), "text"); 72 InsertRecord(shell(), "text");
79 CompareRecords(shell(), "text"); 73 CompareRecords(shell(), "text");
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 Navigate(otr1); 254 Navigate(otr1);
261 CreateTable(otr1); 255 CreateTable(otr1);
262 InsertRecord(otr1, "text"); 256 InsertRecord(otr1, "text");
263 257
264 Shell* otr2 = CreateOffTheRecordBrowser(); 258 Shell* otr2 = CreateOffTheRecordBrowser();
265 Navigate(otr2); 259 Navigate(otr2);
266 CompareRecords(otr2, "text"); 260 CompareRecords(otr2, "text");
267 } 261 }
268 262
269 } // namespace content 263 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698