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