| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/instant/instant_test_utils.h" | 5 #include "chrome/browser/instant/instant_test_utils.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "chrome/browser/prefs/pref_service.h" | 8 #include "chrome/browser/prefs/pref_service.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/search_engines/template_url_service.h" | 10 #include "chrome/browser/search_engines/template_url_service.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 if (model.mode().mode == desired_mode_type_) | 50 if (model.mode().mode == desired_mode_type_) |
| 51 run_loop_.Quit(); | 51 run_loop_.Quit(); |
| 52 } | 52 } |
| 53 | 53 |
| 54 // InstantTestBase ----------------------------------------------------------- | 54 // InstantTestBase ----------------------------------------------------------- |
| 55 | 55 |
| 56 void InstantTestBase::SetupInstant() { | 56 void InstantTestBase::SetupInstant() { |
| 57 CommandLine::ForCurrentProcess()->AppendSwitchASCII( | 57 CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
| 58 switches::kInstantURL, instant_url_.spec()); | 58 switches::kInstantURL, instant_url_.spec()); |
| 59 SetupInstantUsingTemplateURL(); | 59 SetupInstantUsingTemplateURL(); |
| 60 |
| 61 // TODO(shishir): Fix this ugly hack. |
| 62 instant()->SetInstantEnabled(false); |
| 63 instant()->SetInstantEnabled(true); |
| 60 } | 64 } |
| 61 | 65 |
| 62 void InstantTestBase::SetupInstantUsingTemplateURL() { | 66 void InstantTestBase::SetupInstantUsingTemplateURL() { |
| 63 TemplateURLService* service = | 67 TemplateURLService* service = |
| 64 TemplateURLServiceFactory::GetForProfile(browser()->profile()); | 68 TemplateURLServiceFactory::GetForProfile(browser()->profile()); |
| 65 ui_test_utils::WaitForTemplateURLServiceToLoad(service); | 69 ui_test_utils::WaitForTemplateURLServiceToLoad(service); |
| 66 | 70 |
| 67 TemplateURLData data; | 71 TemplateURLData data; |
| 68 data.SetURL("http://does/not/exist?q={searchTerms}"); | 72 data.SetURL("http://does/not/exist?q={searchTerms}"); |
| 69 data.instant_url = instant_url_.spec(); | 73 data.instant_url = instant_url_.spec(); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 } | 142 } |
| 139 | 143 |
| 140 bool InstantTestBase::CheckVisibilityIs(content::WebContents* contents, | 144 bool InstantTestBase::CheckVisibilityIs(content::WebContents* contents, |
| 141 bool expected) { | 145 bool expected) { |
| 142 bool actual = !expected; // Purposely start with a mis-match. | 146 bool actual = !expected; // Purposely start with a mis-match. |
| 143 // We can only use ASSERT_*() in a method that returns void, hence this | 147 // We can only use ASSERT_*() in a method that returns void, hence this |
| 144 // convoluted check. | 148 // convoluted check. |
| 145 return GetBoolFromJS(contents, "!document.webkitHidden", &actual) && | 149 return GetBoolFromJS(contents, "!document.webkitHidden", &actual) && |
| 146 actual == expected; | 150 actual == expected; |
| 147 } | 151 } |
| OLD | NEW |