| OLD | NEW |
| 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/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/path_service.h" | 6 #include "base/path_service.h" |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/browser/infobars/confirm_infobar_delegate.h" | 8 #include "chrome/browser/infobars/confirm_infobar_delegate.h" |
| 9 #include "chrome/browser/infobars/infobar_service.h" | 9 #include "chrome/browser/infobars/infobar_service.h" |
| 10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
| 11 #include "chrome/browser/ui/browser_commands.h" | 11 #include "chrome/browser/ui/browser_commands.h" |
| 12 #include "chrome/browser/ui/browser_navigator.h" | 12 #include "chrome/browser/ui/browser_navigator.h" |
| 13 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 13 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 14 #include "chrome/common/chrome_notification_types.h" | 14 #include "chrome/common/chrome_notification_types.h" |
| 15 #include "chrome/common/chrome_paths.h" | 15 #include "chrome/common/chrome_paths.h" |
| 16 #include "chrome/common/chrome_switches.h" | 16 #include "chrome/common/chrome_switches.h" |
| 17 #include "chrome/common/url_constants.h" | 17 #include "chrome/common/url_constants.h" |
| 18 #include "chrome/test/base/in_process_browser_test.h" | 18 #include "chrome/test/base/in_process_browser_test.h" |
| 19 #include "chrome/test/base/test_launcher_utils.h" | 19 #include "chrome/test/base/test_launcher_utils.h" |
| 20 #include "chrome/test/base/ui_test_utils.h" | 20 #include "chrome/test/base/ui_test_utils.h" |
| 21 #include "content/public/browser/gpu_data_manager.h" | 21 #include "content/public/browser/gpu_data_manager.h" |
| 22 #include "content/public/browser/notification_service.h" | 22 #include "content/public/browser/notification_service.h" |
| 23 #include "content/public/browser/notification_types.h" | 23 #include "content/public/browser/notification_types.h" |
| 24 #include "content/public/common/content_paths.h" | 24 #include "content/public/common/content_paths.h" |
| 25 #include "content/public/common/page_transition_types.h" | 25 #include "content/public/common/page_transition_types.h" |
| 26 #include "content/public/test/browser_test_utils.h" | 26 #include "content/public/test/browser_test_utils.h" |
| 27 #include "content/test/gpu/gpu_test_config.h" | 27 #include "gpu/config/gpu_test_config.h" |
| 28 #include "testing/gtest/include/gtest/gtest.h" | 28 #include "testing/gtest/include/gtest/gtest.h" |
| 29 #include "ui/gl/gl_implementation.h" | 29 #include "ui/gl/gl_implementation.h" |
| 30 | 30 |
| 31 namespace { | 31 namespace { |
| 32 | 32 |
| 33 void SimulateGPUCrash(Browser* browser) { | 33 void SimulateGPUCrash(Browser* browser) { |
| 34 // None of the ui_test_utils entry points supports what we need to | 34 // None of the ui_test_utils entry points supports what we need to |
| 35 // do here: navigate with the PAGE_TRANSITION_FROM_ADDRESS_BAR flag, | 35 // do here: navigate with the PAGE_TRANSITION_FROM_ADDRESS_BAR flag, |
| 36 // without waiting for the navigation. It would be painful to change | 36 // without waiting for the navigation. It would be painful to change |
| 37 // either of the NavigateToURL entry points to support these two | 37 // either of the NavigateToURL entry points to support these two |
| (...skipping 21 matching lines...) Expand all Loading... |
| 59 } | 59 } |
| 60 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { | 60 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { |
| 61 base::FilePath test_dir; | 61 base::FilePath test_dir; |
| 62 ASSERT_TRUE(PathService::Get(content::DIR_TEST_DATA, &test_dir)); | 62 ASSERT_TRUE(PathService::Get(content::DIR_TEST_DATA, &test_dir)); |
| 63 gpu_test_dir_ = test_dir.AppendASCII("gpu"); | 63 gpu_test_dir_ = test_dir.AppendASCII("gpu"); |
| 64 } | 64 } |
| 65 base::FilePath gpu_test_dir_; | 65 base::FilePath gpu_test_dir_; |
| 66 }; | 66 }; |
| 67 | 67 |
| 68 IN_PROC_BROWSER_TEST_F(WebGLInfobarTest, ContextLossRaisesInfobar) { | 68 IN_PROC_BROWSER_TEST_F(WebGLInfobarTest, ContextLossRaisesInfobar) { |
| 69 if (GPUTestBotConfig::CurrentConfigMatches("XP")) | 69 if (gpu::GPUTestBotConfig::CurrentConfigMatches("XP")) |
| 70 return; | 70 return; |
| 71 | 71 |
| 72 // Load page and wait for it to load. | 72 // Load page and wait for it to load. |
| 73 content::WindowedNotificationObserver observer( | 73 content::WindowedNotificationObserver observer( |
| 74 content::NOTIFICATION_LOAD_STOP, | 74 content::NOTIFICATION_LOAD_STOP, |
| 75 content::NotificationService::AllSources()); | 75 content::NotificationService::AllSources()); |
| 76 ui_test_utils::NavigateToURL( | 76 ui_test_utils::NavigateToURL( |
| 77 browser(), | 77 browser(), |
| 78 content::GetFileUrlWithQuery( | 78 content::GetFileUrlWithQuery( |
| 79 gpu_test_dir_.AppendASCII("webgl.html"), "query=kill")); | 79 gpu_test_dir_.AppendASCII("webgl.html"), "query=kill")); |
| 80 observer.Wait(); | 80 observer.Wait(); |
| 81 | 81 |
| 82 content::WindowedNotificationObserver infobar_added( | 82 content::WindowedNotificationObserver infobar_added( |
| 83 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, | 83 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, |
| 84 content::NotificationService::AllSources()); | 84 content::NotificationService::AllSources()); |
| 85 SimulateGPUCrash(browser()); | 85 SimulateGPUCrash(browser()); |
| 86 infobar_added.Wait(); | 86 infobar_added.Wait(); |
| 87 EXPECT_EQ(1u, | 87 EXPECT_EQ(1u, |
| 88 InfoBarService::FromWebContents( | 88 InfoBarService::FromWebContents( |
| 89 browser()->tab_strip_model()->GetActiveWebContents())-> | 89 browser()->tab_strip_model()->GetActiveWebContents())-> |
| 90 infobar_count()); | 90 infobar_count()); |
| 91 } | 91 } |
| 92 | 92 |
| 93 IN_PROC_BROWSER_TEST_F(WebGLInfobarTest, ContextLossInfobarReload) { | 93 IN_PROC_BROWSER_TEST_F(WebGLInfobarTest, ContextLossInfobarReload) { |
| 94 if (GPUTestBotConfig::CurrentConfigMatches("XP")) | 94 if (gpu::GPUTestBotConfig::CurrentConfigMatches("XP")) |
| 95 return; | 95 return; |
| 96 | 96 |
| 97 content::DOMMessageQueue message_queue; | 97 content::DOMMessageQueue message_queue; |
| 98 | 98 |
| 99 // Load page and wait for it to load. | 99 // Load page and wait for it to load. |
| 100 content::WindowedNotificationObserver observer( | 100 content::WindowedNotificationObserver observer( |
| 101 content::NOTIFICATION_LOAD_STOP, | 101 content::NOTIFICATION_LOAD_STOP, |
| 102 content::NotificationService::AllSources()); | 102 content::NotificationService::AllSources()); |
| 103 ui_test_utils::NavigateToURL( | 103 ui_test_utils::NavigateToURL( |
| 104 browser(), | 104 browser(), |
| (...skipping 24 matching lines...) Expand all Loading... |
| 129 // The page should reload and another message sent to the | 129 // The page should reload and another message sent to the |
| 130 // DomAutomationController. | 130 // DomAutomationController. |
| 131 m = ""; | 131 m = ""; |
| 132 ASSERT_TRUE(message_queue.WaitForMessage(&m)); | 132 ASSERT_TRUE(message_queue.WaitForMessage(&m)); |
| 133 EXPECT_EQ("\"LOADED\"", m); | 133 EXPECT_EQ("\"LOADED\"", m); |
| 134 } | 134 } |
| 135 | 135 |
| 136 // There isn't any point in adding a test which calls Accept() on the | 136 // There isn't any point in adding a test which calls Accept() on the |
| 137 // ThreeDAPIInfoBarDelegate; doing so doesn't remove the infobar, and | 137 // ThreeDAPIInfoBarDelegate; doing so doesn't remove the infobar, and |
| 138 // there's no concrete event that could be observed in response. | 138 // there's no concrete event that could be observed in response. |
| OLD | NEW |