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

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

Issue 1086733002: Ensure tests have an active task runner (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 5 years, 8 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/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/memory/scoped_ptr.h" 6 #include "base/memory/scoped_ptr.h"
7 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "chrome/browser/browser_about_handler.h" 8 #include "chrome/browser/browser_about_handler.h"
9 #include "chrome/common/url_constants.h" 9 #include "chrome/common/url_constants.h"
10 #include "chrome/test/base/testing_profile.h" 10 #include "chrome/test/base/testing_profile.h"
11 #include "content/public/browser/navigation_controller.h" 11 #include "content/public/browser/navigation_controller.h"
12 #include "content/public/browser/navigation_entry.h" 12 #include "content/public/browser/navigation_entry.h"
13 #include "content/public/common/referrer.h" 13 #include "content/public/common/referrer.h"
14 #include "content/public/test/test_browser_thread.h" 14 #include "content/public/test/test_browser_thread.h"
15 #include "content/public/test/test_browser_thread_bundle.h"
15 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
16 #include "url/gurl.h" 17 #include "url/gurl.h"
17 18
18 using content::BrowserThread; 19 using content::BrowserThread;
19 using content::NavigationController; 20 using content::NavigationController;
20 using content::NavigationEntry; 21 using content::NavigationEntry;
21 using content::Referrer; 22 using content::Referrer;
22 23
23 typedef testing::Test BrowserAboutHandlerTest; 24 class BrowserAboutHandlerTest : public testing::Test {
25 content::TestBrowserThreadBundle thread_bundle_;
26 };
24 27
25 TEST_F(BrowserAboutHandlerTest, WillHandleBrowserAboutURL) { 28 TEST_F(BrowserAboutHandlerTest, WillHandleBrowserAboutURL) {
26 std::string chrome_prefix(content::kChromeUIScheme); 29 std::string chrome_prefix(content::kChromeUIScheme);
27 chrome_prefix.append(url::kStandardSchemeSeparator); 30 chrome_prefix.append(url::kStandardSchemeSeparator);
28 struct AboutURLTestData { 31 struct AboutURLTestData {
29 GURL test_url; 32 GURL test_url;
30 GURL result_url; 33 GURL result_url;
31 } test_data[] = { 34 } test_data[] = {
32 { 35 {
33 GURL("http://google.com"), 36 GURL("http://google.com"),
(...skipping 29 matching lines...) Expand all
63 }, 66 },
64 { 67 {
65 GURL(chrome_prefix + chrome::kChromeUIInvalidationsHost), 68 GURL(chrome_prefix + chrome::kChromeUIInvalidationsHost),
66 GURL(chrome_prefix + chrome::kChromeUIInvalidationsHost) 69 GURL(chrome_prefix + chrome::kChromeUIInvalidationsHost)
67 }, 70 },
68 { 71 {
69 GURL(chrome_prefix + "host/path?query#ref"), 72 GURL(chrome_prefix + "host/path?query#ref"),
70 GURL(chrome_prefix + "host/path?query#ref"), 73 GURL(chrome_prefix + "host/path?query#ref"),
71 } 74 }
72 }; 75 };
73 base::MessageLoopForUI message_loop;
74 content::TestBrowserThread ui_thread(BrowserThread::UI, &message_loop);
75 TestingProfile profile; 76 TestingProfile profile;
76 77
77 for (size_t i = 0; i < arraysize(test_data); ++i) { 78 for (size_t i = 0; i < arraysize(test_data); ++i) {
78 GURL url(test_data[i].test_url); 79 GURL url(test_data[i].test_url);
79 WillHandleBrowserAboutURL(&url, &profile); 80 WillHandleBrowserAboutURL(&url, &profile);
80 EXPECT_EQ(test_data[i].result_url, url); 81 EXPECT_EQ(test_data[i].result_url, url);
81 } 82 }
82 } 83 }
83 84
84 // Ensure that minor BrowserAboutHandler fixup to a URL does not cause us to 85 // Ensure that minor BrowserAboutHandler fixup to a URL does not cause us to
85 // keep a separate virtual URL, which would not be updated on redirects. 86 // keep a separate virtual URL, which would not be updated on redirects.
86 // See https://crbug.com/449829. 87 // See https://crbug.com/449829.
87 TEST_F(BrowserAboutHandlerTest, NoVirtualURLForFixup) { 88 TEST_F(BrowserAboutHandlerTest, NoVirtualURLForFixup) {
88 GURL url("view-source:http://.foo"); 89 GURL url("view-source:http://.foo");
89 90
90 // Fixup will remove the dot and add a slash. 91 // Fixup will remove the dot and add a slash.
91 GURL fixed_url("view-source:http://foo/"); 92 GURL fixed_url("view-source:http://foo/");
92 93
93 // Rewriters will remove the view-source prefix and expect it to stay in the 94 // Rewriters will remove the view-source prefix and expect it to stay in the
94 // virtual URL. 95 // virtual URL.
95 GURL rewritten_url("http://foo/"); 96 GURL rewritten_url("http://foo/");
96 97
97 TestingProfile profile; 98 TestingProfile profile;
98 scoped_ptr<NavigationEntry> entry(NavigationController::CreateNavigationEntry( 99 scoped_ptr<NavigationEntry> entry(NavigationController::CreateNavigationEntry(
99 url, Referrer(), ui::PAGE_TRANSITION_RELOAD, false, std::string(), 100 url, Referrer(), ui::PAGE_TRANSITION_RELOAD, false, std::string(),
100 &profile)); 101 &profile));
101 EXPECT_EQ(fixed_url, entry->GetVirtualURL()); 102 EXPECT_EQ(fixed_url, entry->GetVirtualURL());
102 EXPECT_EQ(rewritten_url, entry->GetURL()); 103 EXPECT_EQ(rewritten_url, entry->GetURL());
103 } 104 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698