| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 34 params->searchable_form_encoding = std::string(); | 34 params->searchable_form_encoding = std::string(); |
| 35 params->password_form = PasswordForm(); | 35 params->password_form = PasswordForm(); |
| 36 params->security_info = std::string(); | 36 params->security_info = std::string(); |
| 37 params->gesture = NavigationGestureUser; | 37 params->gesture = NavigationGestureUser; |
| 38 params->is_post = false; | 38 params->is_post = false; |
| 39 } | 39 } |
| 40 | 40 |
| 41 // Subclass the TestingProfile so that it can return certain services we need. | 41 // Subclass the TestingProfile so that it can return certain services we need. |
| 42 class TabContentsTestingProfile : public TestingProfile { | 42 class TabContentsTestingProfile : public TestingProfile { |
| 43 public: | 43 public: |
| 44 TabContentsTestingProfile() : TestingProfile() {} | 44 TabContentsTestingProfile() : TestingProfile() { } |
| 45 | 45 |
| 46 virtual PrefService* GetPrefs() { | 46 virtual PrefService* GetPrefs() { |
| 47 if (!prefs_.get()) { | 47 if (!prefs_.get()) { |
| 48 FilePath source_path; | 48 FilePath source_path; |
| 49 PathService::Get(chrome::DIR_TEST_DATA, &source_path); | 49 PathService::Get(chrome::DIR_TEST_DATA, &source_path); |
| 50 source_path = source_path.AppendASCII("profiles") | 50 source_path = source_path.AppendASCII("profiles") |
| 51 .AppendASCII("chrome_prefs").AppendASCII("Preferences"); | 51 .AppendASCII("chrome_prefs").AppendASCII("Preferences"); |
| 52 | 52 |
| 53 prefs_.reset(new PrefService(source_path, NULL)); | 53 prefs_.reset(new PrefService(source_path, NULL)); |
| 54 Profile::RegisterUserPrefs(prefs_.get()); | 54 Profile::RegisterUserPrefs(prefs_.get()); |
| 55 browser::RegisterAllPrefs(prefs_.get(), prefs_.get()); | 55 browser::RegisterAllPrefs(prefs_.get(), prefs_.get()); |
| 56 } | 56 } |
| 57 return prefs_.get(); | 57 return prefs_.get(); |
| 58 } | 58 } |
| 59 }; | 59 }; |
| 60 | 60 |
| 61 class TestInterstitialPage : public InterstitialPage { | 61 class TestInterstitialPage : public InterstitialPage { |
| 62 public: | 62 public: |
| 63 enum InterstitialState { | 63 enum InterstitialState { |
| 64 UNDECIDED = 0, // No decision taken yet. | 64 UNDECIDED = 0, // No decision taken yet. |
| 65 OKED, // Proceed was called. | 65 OKED, // Proceed was called. |
| 66 CANCELED // DontProceed was called. | 66 CANCELED // DontProceed was called. |
| 67 }; | 67 }; |
| 68 | 68 |
| 69 class Delegate { | 69 class Delegate { |
| 70 public: | 70 public: |
| 71 virtual void TestInterstitialPageDeleted( | 71 virtual void TestInterstitialPageDeleted( |
| 72 TestInterstitialPage* interstitial) = 0; | 72 TestInterstitialPage* interstitial) = 0; |
| 73 protected: | |
| 74 ~Delegate() {} | |
| 75 }; | 73 }; |
| 76 | 74 |
| 77 // IMPORTANT NOTE: if you pass stack allocated values for |state| and | 75 // IMPORTANT NOTE: if you pass stack allocated values for |state| and |
| 78 // |deleted| (like all interstitial related tests do at this point), make sure | 76 // |deleted| (like all interstitial related tests do at this point), make sure |
| 79 // to create an instance of the TestInterstitialPageStateGuard class on the | 77 // to create an instance of the TestInterstitialPageStateGuard class on the |
| 80 // stack in your test. This will ensure that the TestInterstitialPage states | 78 // stack in your test. This will ensure that the TestInterstitialPage states |
| 81 // are cleared when the test finishes. | 79 // are cleared when the test finishes. |
| 82 // Not doing so will cause stack trashing if your test does not hide the | 80 // Not doing so will cause stack trashing if your test does not hide the |
| 83 // interstitial, as in such a case it will be destroyed in the test TearDown | 81 // interstitial, as in such a case it will be destroyed in the test TearDown |
| 84 // method and will dereference the |deleted| local variable which by then is | 82 // method and will dereference the |deleted| local variable which by then is |
| (...skipping 1200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1285 | 1283 |
| 1286 // While the interstitial is showing, let's simulate the hidden page | 1284 // While the interstitial is showing, let's simulate the hidden page |
| 1287 // attempting to show a JS message. | 1285 // attempting to show a JS message. |
| 1288 IPC::Message* dummy_message = new IPC::Message; | 1286 IPC::Message* dummy_message = new IPC::Message; |
| 1289 bool did_suppress_message = false; | 1287 bool did_suppress_message = false; |
| 1290 contents()->RunJavaScriptMessage(L"This is an informative message", L"OK", | 1288 contents()->RunJavaScriptMessage(L"This is an informative message", L"OK", |
| 1291 kGURL, MessageBoxFlags::kIsJavascriptAlert, dummy_message, | 1289 kGURL, MessageBoxFlags::kIsJavascriptAlert, dummy_message, |
| 1292 &did_suppress_message); | 1290 &did_suppress_message); |
| 1293 EXPECT_TRUE(did_suppress_message); | 1291 EXPECT_TRUE(did_suppress_message); |
| 1294 } | 1292 } |
| OLD | NEW |