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

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

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

Powered by Google App Engine
This is Rietveld 408576698