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

Side by Side Diff: content/browser/renderer_host/render_view_host_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 "base/time.h" 5 #include "base/time.h"
6 #include "base/utf_string_conversions.h" 6 #include "base/utf_string_conversions.h"
7 #include "base/values.h" 7 #include "base/values.h"
8 #include "chrome/browser/ui/browser.h" 8 #include "chrome/browser/ui/browser.h"
9 #include "chrome/browser/ui/browser_tabstrip.h"
9 #include "chrome/test/base/in_process_browser_test.h" 10 #include "chrome/test/base/in_process_browser_test.h"
10 #include "chrome/test/base/ui_test_utils.h" 11 #include "chrome/test/base/ui_test_utils.h"
11 #include "content/browser/renderer_host/render_view_host_impl.h" 12 #include "content/browser/renderer_host/render_view_host_impl.h"
12 #include "content/browser/web_contents/web_contents_impl.h" 13 #include "content/browser/web_contents/web_contents_impl.h"
13 #include "content/common/view_messages.h" 14 #include "content/common/view_messages.h"
14 #include "content/public/browser/notification_types.h" 15 #include "content/public/browser/notification_types.h"
15 #include "content/public/browser/web_contents_observer.h" 16 #include "content/public/browser/web_contents_observer.h"
16 #include "net/base/host_port_pair.h" 17 #include "net/base/host_port_pair.h"
17 #include "net/base/net_util.h" 18 #include "net/base/net_util.h"
18 #include "net/test/test_server.h" 19 #include "net/test/test_server.h"
19 20
20 using content::RenderViewHostImpl; 21 using content::RenderViewHostImpl;
21 using content::WebContents; 22 using content::WebContents;
22 23
23 class RenderViewHostTest : public InProcessBrowserTest { 24 class RenderViewHostTest : public InProcessBrowserTest {
24 public: 25 public:
25 RenderViewHostTest() {} 26 RenderViewHostTest() {}
26 }; 27 };
27 28
28 29
29 IN_PROC_BROWSER_TEST_F(RenderViewHostTest, 30 IN_PROC_BROWSER_TEST_F(RenderViewHostTest,
30 ExecuteJavascriptAndGetValue) { 31 ExecuteJavascriptAndGetValue) {
31 ASSERT_TRUE(test_server()->Start()); 32 ASSERT_TRUE(test_server()->Start());
32 GURL empty_url(test_server()->GetURL("files/empty.html")); 33 GURL empty_url(test_server()->GetURL("files/empty.html"));
33 ui_test_utils::NavigateToURL(browser(), empty_url); 34 ui_test_utils::NavigateToURL(browser(), empty_url);
34 35
35 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( 36 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>(
36 browser()->GetActiveWebContents()->GetRenderViewHost()); 37 chrome::GetActiveWebContents(browser())->GetRenderViewHost());
37 38
38 { 39 {
39 scoped_ptr<Value> value( 40 scoped_ptr<Value> value(
40 rvh->ExecuteJavascriptAndGetValue(string16(), ASCIIToUTF16("!false;"))); 41 rvh->ExecuteJavascriptAndGetValue(string16(), ASCIIToUTF16("!false;")));
41 EXPECT_EQ(Value::TYPE_BOOLEAN, value->GetType()); 42 EXPECT_EQ(Value::TYPE_BOOLEAN, value->GetType());
42 bool bool_value; 43 bool bool_value;
43 EXPECT_TRUE(value->GetAsBoolean(&bool_value)); 44 EXPECT_TRUE(value->GetAsBoolean(&bool_value));
44 EXPECT_TRUE(bool_value); 45 EXPECT_TRUE(bool_value);
45 } 46 }
46 47
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 net::HostPortPair observed_socket_address_; 200 net::HostPortPair observed_socket_address_;
200 GURL base_url_; 201 GURL base_url_;
201 int navigation_count_; 202 int navigation_count_;
202 203
203 DISALLOW_COPY_AND_ASSIGN(RenderViewHostTestWebContentsObserver); 204 DISALLOW_COPY_AND_ASSIGN(RenderViewHostTestWebContentsObserver);
204 }; 205 };
205 206
206 IN_PROC_BROWSER_TEST_F(RenderViewHostTest, FrameNavigateSocketAddress) { 207 IN_PROC_BROWSER_TEST_F(RenderViewHostTest, FrameNavigateSocketAddress) {
207 ASSERT_TRUE(test_server()->Start()); 208 ASSERT_TRUE(test_server()->Start());
208 RenderViewHostTestWebContentsObserver observer( 209 RenderViewHostTestWebContentsObserver observer(
209 browser()->GetActiveWebContents()); 210 chrome::GetActiveWebContents(browser()));
210 211
211 GURL test_url = test_server()->GetURL("files/simple.html"); 212 GURL test_url = test_server()->GetURL("files/simple.html");
212 ui_test_utils::NavigateToURL(browser(), test_url); 213 ui_test_utils::NavigateToURL(browser(), test_url);
213 214
214 EXPECT_EQ(test_server()->host_port_pair().ToString(), 215 EXPECT_EQ(test_server()->host_port_pair().ToString(),
215 observer.observed_socket_address().ToString()); 216 observer.observed_socket_address().ToString());
216 EXPECT_EQ(1, observer.navigation_count()); 217 EXPECT_EQ(1, observer.navigation_count());
217 } 218 }
218 219
219 IN_PROC_BROWSER_TEST_F(RenderViewHostTest, BaseURLParam) { 220 IN_PROC_BROWSER_TEST_F(RenderViewHostTest, BaseURLParam) {
220 ASSERT_TRUE(test_server()->Start()); 221 ASSERT_TRUE(test_server()->Start());
221 RenderViewHostTestWebContentsObserver observer( 222 RenderViewHostTestWebContentsObserver observer(
222 browser()->GetActiveWebContents()); 223 chrome::GetActiveWebContents(browser()));
223 224
224 // Base URL is not set if it is the same as the URL. 225 // Base URL is not set if it is the same as the URL.
225 GURL test_url = test_server()->GetURL("files/simple.html"); 226 GURL test_url = test_server()->GetURL("files/simple.html");
226 ui_test_utils::NavigateToURL(browser(), test_url); 227 ui_test_utils::NavigateToURL(browser(), test_url);
227 EXPECT_TRUE(observer.base_url().is_empty()); 228 EXPECT_TRUE(observer.base_url().is_empty());
228 EXPECT_EQ(1, observer.navigation_count()); 229 EXPECT_EQ(1, observer.navigation_count());
229 230
230 // But should be set to the original page when reading MHTML. 231 // But should be set to the original page when reading MHTML.
231 test_url = net::FilePathToFileURL(test_server()->document_root().Append( 232 test_url = net::FilePathToFileURL(test_server()->document_root().Append(
232 FILE_PATH_LITERAL("google.mht"))); 233 FILE_PATH_LITERAL("google.mht")));
233 ui_test_utils::NavigateToURL(browser(), test_url); 234 ui_test_utils::NavigateToURL(browser(), test_url);
234 EXPECT_EQ("http://www.google.com/", observer.base_url().spec()); 235 EXPECT_EQ("http://www.google.com/", observer.base_url().spec());
235 } 236 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698