OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/renderer_host/test/test_render_view_host.h" | 5 #include "chrome/browser/renderer_host/test/test_render_view_host.h" |
6 | 6 |
7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "chrome/app/chrome_command_ids.h" | 8 #include "chrome/app/chrome_command_ids.h" |
9 #include "chrome/browser/prefs/pref_service.h" | 9 #include "chrome/browser/prefs/pref_service.h" |
10 #include "chrome/browser/prefs/pref_change_registrar.h" | 10 #include "chrome/browser/prefs/pref_change_registrar.h" |
11 #include "chrome/browser/renderer_host/mock_render_process_host.h" | 11 #include "chrome/browser/renderer_host/mock_render_process_host.h" |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 Source<TabContents>(contents())); | 174 Source<TabContents>(contents())); |
175 | 175 |
176 RenderViewHostTestHarness::TearDown(); | 176 RenderViewHostTestHarness::TearDown(); |
177 | 177 |
178 URLFetcher::set_factory(NULL); | 178 URLFetcher::set_factory(NULL); |
179 } | 179 } |
180 | 180 |
181 void SimulateURLFetch(bool success) { | 181 void SimulateURLFetch(bool success) { |
182 TestURLFetcher* fetcher = url_fetcher_factory_.GetFetcherByID(0); | 182 TestURLFetcher* fetcher = url_fetcher_factory_.GetFetcherByID(0); |
183 ASSERT_TRUE(fetcher); | 183 ASSERT_TRUE(fetcher); |
184 URLRequestStatus status; | 184 net::URLRequestStatus status; |
185 status.set_status(success ? URLRequestStatus::SUCCESS : | 185 status.set_status(success ? net::URLRequestStatus::SUCCESS : |
186 URLRequestStatus::FAILED); | 186 net::URLRequestStatus::FAILED); |
187 fetcher->delegate()->OnURLFetchComplete(fetcher, fetcher->original_url(), | 187 fetcher->delegate()->OnURLFetchComplete(fetcher, fetcher->original_url(), |
188 status, success ? 200 : 500, | 188 status, success ? 200 : 500, |
189 ResponseCookies(), | 189 ResponseCookies(), |
190 std::string()); | 190 std::string()); |
191 } | 191 } |
192 | 192 |
193 void SetPrefObserverExpectation(const char* path) { | 193 void SetPrefObserverExpectation(const char* path) { |
194 EXPECT_CALL( | 194 EXPECT_CALL( |
195 pref_observer_, | 195 pref_observer_, |
196 Observe(NotificationType(NotificationType::PREF_CHANGED), | 196 Observe(NotificationType(NotificationType::PREF_CHANGED), |
(...skipping 1025 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1222 NULL); | 1222 NULL); |
1223 // Now simulate the URL fetch. | 1223 // Now simulate the URL fetch. |
1224 SimulateURLFetch(true); | 1224 SimulateURLFetch(true); |
1225 // Now the message should have been sent. | 1225 // Now the message should have been sent. |
1226 int page_id = 0; | 1226 int page_id = 0; |
1227 std::string original_lang, target_lang; | 1227 std::string original_lang, target_lang; |
1228 EXPECT_TRUE(GetTranslateMessage(&page_id, &original_lang, &target_lang)); | 1228 EXPECT_TRUE(GetTranslateMessage(&page_id, &original_lang, &target_lang)); |
1229 EXPECT_EQ("es", original_lang); | 1229 EXPECT_EQ("es", original_lang); |
1230 EXPECT_EQ("en", target_lang); | 1230 EXPECT_EQ("en", target_lang); |
1231 } | 1231 } |
OLD | NEW |