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

Side by Side Diff: chrome/browser/loadtimes_extension_bindings_browsertest.cc

Issue 12066003: Remove TabStripModel wrapper use. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: gtk Created 7 years, 10 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
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 "chrome/browser/ui/browser.h" 5 #include "chrome/browser/ui/browser.h"
6 #include "chrome/browser/ui/browser_tabstrip.h" 6 #include "chrome/browser/ui/tabs/tab_strip_model.h"
7 #include "chrome/test/base/in_process_browser_test.h" 7 #include "chrome/test/base/in_process_browser_test.h"
8 #include "chrome/test/base/ui_test_utils.h" 8 #include "chrome/test/base/ui_test_utils.h"
9 #include "content/public/browser/web_contents.h" 9 #include "content/public/browser/web_contents.h"
10 #include "content/public/test/browser_test_utils.h" 10 #include "content/public/test/browser_test_utils.h"
11 #include "net/test/test_server.h" 11 #include "net/test/test_server.h"
12 12
13 class LoadtimesExtensionBindingsTest : public InProcessBrowserTest { 13 class LoadtimesExtensionBindingsTest : public InProcessBrowserTest {
14 public: 14 public:
15 LoadtimesExtensionBindingsTest() {} 15 LoadtimesExtensionBindingsTest() {}
16 16
17 void CompareBeforeAndAfter() { 17 void CompareBeforeAndAfter() {
18 // TODO(simonjam): There's a race on whether or not first paint is populated 18 // TODO(simonjam): There's a race on whether or not first paint is populated
19 // before we read them. We ought to test that too. Until the race is fixed, 19 // before we read them. We ought to test that too. Until the race is fixed,
20 // zero it out so the test is stable. 20 // zero it out so the test is stable.
21 content::WebContents* contents = chrome::GetActiveWebContents(browser()); 21 content::WebContents* contents =
22 browser()->tab_strip_model()->GetActiveWebContents();
22 ASSERT_TRUE(content::ExecuteScript( 23 ASSERT_TRUE(content::ExecuteScript(
23 contents, 24 contents,
24 "window.before.firstPaintAfterLoadTime = 0;" 25 "window.before.firstPaintAfterLoadTime = 0;"
25 "window.before.firstPaintTime = 0;" 26 "window.before.firstPaintTime = 0;"
26 "window.after.firstPaintAfterLoadTime = 0;" 27 "window.after.firstPaintAfterLoadTime = 0;"
27 "window.after.firstPaintTime = 0;")); 28 "window.after.firstPaintTime = 0;"));
28 29
29 std::string before; 30 std::string before;
30 std::string after; 31 std::string after;
31 ASSERT_TRUE(content::ExecuteScriptAndExtractString( 32 ASSERT_TRUE(content::ExecuteScriptAndExtractString(
32 contents, 33 contents,
33 "window.domAutomationController.send(" 34 "window.domAutomationController.send("
34 " JSON.stringify(before))", 35 " JSON.stringify(before))",
35 &before)); 36 &before));
36 ASSERT_TRUE(content::ExecuteScriptAndExtractString( 37 ASSERT_TRUE(content::ExecuteScriptAndExtractString(
37 contents, 38 contents,
38 "window.domAutomationController.send(" 39 "window.domAutomationController.send("
39 " JSON.stringify(after))", 40 " JSON.stringify(after))",
40 &after)); 41 &after));
41 EXPECT_EQ(before, after); 42 EXPECT_EQ(before, after);
42 } 43 }
43 }; 44 };
44 45
45 IN_PROC_BROWSER_TEST_F(LoadtimesExtensionBindingsTest, 46 IN_PROC_BROWSER_TEST_F(LoadtimesExtensionBindingsTest,
46 LoadTimesSameAfterClientInDocNavigation) { 47 LoadTimesSameAfterClientInDocNavigation) {
47 ASSERT_TRUE(test_server()->Start()); 48 ASSERT_TRUE(test_server()->Start());
48 GURL plain_url = test_server()->GetURL("blank"); 49 GURL plain_url = test_server()->GetURL("blank");
49 ui_test_utils::NavigateToURL(browser(), plain_url); 50 ui_test_utils::NavigateToURL(browser(), plain_url);
50 content::WebContents* contents = chrome::GetActiveWebContents(browser()); 51 content::WebContents* contents =
52 browser()->tab_strip_model()->GetActiveWebContents();
51 ASSERT_TRUE(content::ExecuteScript( 53 ASSERT_TRUE(content::ExecuteScript(
52 contents, "window.before = window.chrome.loadTimes()")); 54 contents, "window.before = window.chrome.loadTimes()"));
53 ASSERT_TRUE(content::ExecuteScript( 55 ASSERT_TRUE(content::ExecuteScript(
54 contents, "window.location.href = window.location + \"#\"")); 56 contents, "window.location.href = window.location + \"#\""));
55 ASSERT_TRUE(content::ExecuteScript( 57 ASSERT_TRUE(content::ExecuteScript(
56 contents, "window.after = window.chrome.loadTimes()")); 58 contents, "window.after = window.chrome.loadTimes()"));
57 CompareBeforeAndAfter(); 59 CompareBeforeAndAfter();
58 } 60 }
59 61
60 IN_PROC_BROWSER_TEST_F(LoadtimesExtensionBindingsTest, 62 IN_PROC_BROWSER_TEST_F(LoadtimesExtensionBindingsTest,
61 LoadTimesSameAfterUserInDocNavigation) { 63 LoadTimesSameAfterUserInDocNavigation) {
62 ASSERT_TRUE(test_server()->Start()); 64 ASSERT_TRUE(test_server()->Start());
63 GURL plain_url = test_server()->GetURL("blank"); 65 GURL plain_url = test_server()->GetURL("blank");
64 GURL hash_url(plain_url.spec() + "#"); 66 GURL hash_url(plain_url.spec() + "#");
65 ui_test_utils::NavigateToURL(browser(), plain_url); 67 ui_test_utils::NavigateToURL(browser(), plain_url);
66 content::WebContents* contents = chrome::GetActiveWebContents(browser()); 68 content::WebContents* contents =
69 browser()->tab_strip_model()->GetActiveWebContents();
67 ASSERT_TRUE(content::ExecuteScript( 70 ASSERT_TRUE(content::ExecuteScript(
68 contents, "window.before = window.chrome.loadTimes()")); 71 contents, "window.before = window.chrome.loadTimes()"));
69 ui_test_utils::NavigateToURL(browser(), hash_url); 72 ui_test_utils::NavigateToURL(browser(), hash_url);
70 ASSERT_TRUE(content::ExecuteScript( 73 ASSERT_TRUE(content::ExecuteScript(
71 contents, "window.after = window.chrome.loadTimes()")); 74 contents, "window.after = window.chrome.loadTimes()"));
72 CompareBeforeAndAfter(); 75 CompareBeforeAndAfter();
73 } 76 }
OLDNEW
« no previous file with comments | « chrome/browser/instant/instant_browsertest.cc ('k') | chrome/browser/managed_mode/managed_mode_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698