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

Side by Side Diff: chrome/browser/tab_contents/web_contents_unittest.cc

Issue 193092: Replace a bunch of hardcoded URLs with constants from url_constants.h... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 3 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
« no previous file with comments | « chrome/browser/tab_contents/tab_contents.cc ('k') | chrome/browser/toolbar_model.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "app/message_box_flags.h" 5 #include "app/message_box_flags.h"
6 #include "base/logging.h" 6 #include "base/logging.h"
7 #include "chrome/browser/renderer_host/render_view_host.h" 7 #include "chrome/browser/renderer_host/render_view_host.h"
8 #include "chrome/browser/renderer_host/render_widget_host_view.h" 8 #include "chrome/browser/renderer_host/render_widget_host_view.h"
9 #include "chrome/browser/renderer_host/test/test_render_view_host.h" 9 #include "chrome/browser/renderer_host/test/test_render_view_host.h"
10 #include "chrome/browser/tab_contents/interstitial_page.h" 10 #include "chrome/browser/tab_contents/interstitial_page.h"
11 #include "chrome/browser/tab_contents/navigation_controller.h" 11 #include "chrome/browser/tab_contents/navigation_controller.h"
12 #include "chrome/browser/tab_contents/navigation_entry.h" 12 #include "chrome/browser/tab_contents/navigation_entry.h"
13 #include "chrome/browser/tab_contents/test_web_contents.h" 13 #include "chrome/browser/tab_contents/test_web_contents.h"
14 #include "chrome/common/chrome_paths.h" 14 #include "chrome/common/chrome_paths.h"
15 #include "chrome/common/pref_service.h" 15 #include "chrome/common/pref_service.h"
16 #include "chrome/common/render_messages.h" 16 #include "chrome/common/render_messages.h"
17 #include "chrome/common/url_constants.h"
17 #include "chrome/test/testing_profile.h" 18 #include "chrome/test/testing_profile.h"
18 #include "ipc/ipc_channel.h" 19 #include "ipc/ipc_channel.h"
19 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
20 21
21 using webkit_glue::PasswordForm; 22 using webkit_glue::PasswordForm;
22 23
23 static void InitNavigateParams(ViewHostMsg_FrameNavigate_Params* params, 24 static void InitNavigateParams(ViewHostMsg_FrameNavigate_Params* params,
24 int page_id, 25 int page_id,
25 const GURL& url) { 26 const GURL& url) {
26 params->page_id = page_id; 27 params->page_id = page_id;
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 // is not supposed to overwrite a profile if it's already created. 200 // is not supposed to overwrite a profile if it's already created.
200 virtual void SetUp() { 201 virtual void SetUp() {
201 profile_.reset(new TabContentsTestingProfile()); 202 profile_.reset(new TabContentsTestingProfile());
202 RenderViewHostTestHarness::SetUp(); 203 RenderViewHostTestHarness::SetUp();
203 } 204 }
204 }; 205 };
205 206
206 // Test to make sure that title updates get stripped of whitespace. 207 // Test to make sure that title updates get stripped of whitespace.
207 TEST_F(TabContentsTest, UpdateTitle) { 208 TEST_F(TabContentsTest, UpdateTitle) {
208 ViewHostMsg_FrameNavigate_Params params; 209 ViewHostMsg_FrameNavigate_Params params;
209 InitNavigateParams(&params, 0, GURL("about:blank")); 210 InitNavigateParams(&params, 0, GURL(chrome::kAboutBlankURL));
210 211
211 NavigationController::LoadCommittedDetails details; 212 NavigationController::LoadCommittedDetails details;
212 controller().RendererDidNavigate(params, &details); 213 controller().RendererDidNavigate(params, &details);
213 214
214 contents()->UpdateTitle(rvh(), 0, L" Lots O' Whitespace\n"); 215 contents()->UpdateTitle(rvh(), 0, L" Lots O' Whitespace\n");
215 EXPECT_EQ(ASCIIToUTF16("Lots O' Whitespace"), contents()->GetTitle()); 216 EXPECT_EQ(ASCIIToUTF16("Lots O' Whitespace"), contents()->GetTitle());
216 } 217 }
217 218
218 // Test view source mode for the new tabs page. 219 // Test view source mode for the new tabs page.
219 TEST_F(TabContentsTest, NTPViewSource) { 220 TEST_F(TabContentsTest, NTPViewSource) {
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 EXPECT_FALSE(entry->content_state().empty()); 549 EXPECT_FALSE(entry->content_state().empty());
549 } 550 }
550 551
551 // Test that NavigationEntries have the correct content state after opening 552 // Test that NavigationEntries have the correct content state after opening
552 // a new window to about:blank. Prevents regression for bug 1116137. 553 // a new window to about:blank. Prevents regression for bug 1116137.
553 TEST_F(TabContentsTest, NavigationEntryContentStateNewWindow) { 554 TEST_F(TabContentsTest, NavigationEntryContentStateNewWindow) {
554 TestRenderViewHost* orig_rvh = rvh(); 555 TestRenderViewHost* orig_rvh = rvh();
555 556
556 // When opening a new window, it is navigated to about:blank internally. 557 // When opening a new window, it is navigated to about:blank internally.
557 // Currently, this results in two DidNavigate events. 558 // Currently, this results in two DidNavigate events.
558 const GURL url("about:blank"); 559 const GURL url(chrome::kAboutBlankURL);
559 ViewHostMsg_FrameNavigate_Params params1; 560 ViewHostMsg_FrameNavigate_Params params1;
560 InitNavigateParams(&params1, 1, url); 561 InitNavigateParams(&params1, 1, url);
561 contents()->TestDidNavigate(orig_rvh, params1); 562 contents()->TestDidNavigate(orig_rvh, params1);
562 contents()->TestDidNavigate(orig_rvh, params1); 563 contents()->TestDidNavigate(orig_rvh, params1);
563 564
564 // Should have a content state here. 565 // Should have a content state here.
565 NavigationEntry* entry = controller().GetLastCommittedEntry(); 566 NavigationEntry* entry = controller().GetLastCommittedEntry();
566 EXPECT_FALSE(entry->content_state().empty()); 567 EXPECT_FALSE(entry->content_state().empty());
567 } 568 }
568 569
(...skipping 714 matching lines...) Expand 10 before | Expand all | Expand 10 after
1283 1284
1284 // While the interstitial is showing, let's simulate the hidden page 1285 // While the interstitial is showing, let's simulate the hidden page
1285 // attempting to show a JS message. 1286 // attempting to show a JS message.
1286 IPC::Message* dummy_message = new IPC::Message; 1287 IPC::Message* dummy_message = new IPC::Message;
1287 bool did_suppress_message = false; 1288 bool did_suppress_message = false;
1288 contents()->RunJavaScriptMessage(L"This is an informative message", L"OK", 1289 contents()->RunJavaScriptMessage(L"This is an informative message", L"OK",
1289 kGURL, MessageBoxFlags::kIsJavascriptAlert, dummy_message, 1290 kGURL, MessageBoxFlags::kIsJavascriptAlert, dummy_message,
1290 &did_suppress_message); 1291 &did_suppress_message);
1291 EXPECT_TRUE(did_suppress_message); 1292 EXPECT_TRUE(did_suppress_message);
1292 } 1293 }
OLDNEW
« no previous file with comments | « chrome/browser/tab_contents/tab_contents.cc ('k') | chrome/browser/toolbar_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698