| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/scoped_ptr.h" | 6 #include "base/scoped_ptr.h" |
| 7 #include "chrome/browser/browser_about_handler.h" | 7 #include "chrome/browser/browser_about_handler.h" |
| 8 #include "chrome/browser/browser_thread.h" |
| 8 #include "chrome/common/about_handler.h" | 9 #include "chrome/common/about_handler.h" |
| 9 #include "chrome/common/url_constants.h" | 10 #include "chrome/common/url_constants.h" |
| 11 #include "chrome/test/testing_profile.h" |
| 10 #include "googleurl/src/gurl.h" | 12 #include "googleurl/src/gurl.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 12 | 14 |
| 13 TEST(BrowserAboutHandlerTest, WillHandleBrowserAboutURL) { | 15 TEST(BrowserAboutHandlerTest, WillHandleBrowserAboutURL) { |
| 14 struct AboutURLTestData { | 16 struct AboutURLTestData { |
| 15 GURL test_url; | 17 GURL test_url; |
| 16 GURL result_url; | 18 GURL result_url; |
| 17 bool about_handled; | 19 bool about_handled; |
| 18 bool browser_handled; | 20 bool browser_handled; |
| 19 } test_data[] = { | 21 } test_data[] = { |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 false, | 91 false, |
| 90 true | 92 true |
| 91 }, | 93 }, |
| 92 { | 94 { |
| 93 GURL("about:mars"), | 95 GURL("about:mars"), |
| 94 GURL("chrome://about/mars"), | 96 GURL("chrome://about/mars"), |
| 95 false, | 97 false, |
| 96 true | 98 true |
| 97 }, | 99 }, |
| 98 }; | 100 }; |
| 101 MessageLoopForUI message_loop; |
| 102 BrowserThread ui_thread(BrowserThread::UI, &message_loop); |
| 103 TestingProfile profile; |
| 99 | 104 |
| 100 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_data); ++i) { | 105 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_data); ++i) { |
| 101 GURL url(test_data[i].test_url); | 106 GURL url(test_data[i].test_url); |
| 102 EXPECT_EQ(test_data[i].about_handled, | 107 EXPECT_EQ(test_data[i].about_handled, |
| 103 chrome_about_handler::WillHandle(url)); | 108 chrome_about_handler::WillHandle(url)); |
| 104 EXPECT_EQ(test_data[i].browser_handled, | 109 EXPECT_EQ(test_data[i].browser_handled, |
| 105 WillHandleBrowserAboutURL(&url, NULL)); | 110 WillHandleBrowserAboutURL(&url, &profile)); |
| 106 EXPECT_EQ(test_data[i].result_url, url); | 111 EXPECT_EQ(test_data[i].result_url, url); |
| 107 } | 112 } |
| 108 | 113 |
| 109 // Crash the browser process for about:inducebrowsercrashforrealz. | 114 // Crash the browser process for about:inducebrowsercrashforrealz. |
| 110 GURL url(chrome::kAboutBrowserCrash); | 115 GURL url(chrome::kAboutBrowserCrash); |
| 111 EXPECT_DEATH(WillHandleBrowserAboutURL(&url, NULL), ""); | 116 EXPECT_DEATH(WillHandleBrowserAboutURL(&url, NULL), ""); |
| 112 } | 117 } |
| OLD | NEW |