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 | 5 |
6 #include <algorithm> | 6 #include <algorithm> |
7 #include <set> | 7 #include <set> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "chrome/browser/translate/translate_infobar_delegate.h" | 21 #include "chrome/browser/translate/translate_infobar_delegate.h" |
22 #include "chrome/browser/translate/translate_manager.h" | 22 #include "chrome/browser/translate/translate_manager.h" |
23 #include "chrome/browser/translate/translate_prefs.h" | 23 #include "chrome/browser/translate/translate_prefs.h" |
24 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 24 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
25 #include "chrome/browser/ui/tab_contents/test_tab_contents_wrapper.h" | 25 #include "chrome/browser/ui/tab_contents/test_tab_contents_wrapper.h" |
26 #include "chrome/common/chrome_notification_types.h" | 26 #include "chrome/common/chrome_notification_types.h" |
27 #include "chrome/common/pref_names.h" | 27 #include "chrome/common/pref_names.h" |
28 #include "chrome/common/render_messages.h" | 28 #include "chrome/common/render_messages.h" |
29 #include "chrome/test/base/testing_browser_process.h" | 29 #include "chrome/test/base/testing_browser_process.h" |
30 #include "chrome/test/base/testing_profile.h" | 30 #include "chrome/test/base/testing_profile.h" |
31 #include "content/browser/tab_contents/test_tab_contents.h" | |
32 #include "content/public/browser/navigation_details.h" | 31 #include "content/public/browser/navigation_details.h" |
33 #include "content/public/browser/navigation_entry.h" | 32 #include "content/public/browser/navigation_entry.h" |
34 #include "content/public/browser/notification_details.h" | 33 #include "content/public/browser/notification_details.h" |
35 #include "content/public/browser/notification_registrar.h" | 34 #include "content/public/browser/notification_registrar.h" |
| 35 #include "content/public/browser/web_contents.h" |
36 #include "content/test/mock_render_process_host.h" | 36 #include "content/test/mock_render_process_host.h" |
37 #include "content/test/notification_observer_mock.h" | 37 #include "content/test/notification_observer_mock.h" |
38 #include "content/test/render_view_test.h" | 38 #include "content/test/render_view_test.h" |
39 #include "content/test/test_browser_thread.h" | 39 #include "content/test/test_browser_thread.h" |
40 #include "content/test/test_renderer_host.h" | 40 #include "content/test/test_renderer_host.h" |
41 #include "content/test/test_renderer_host.h" | 41 #include "content/test/test_renderer_host.h" |
42 #include "content/test/test_url_fetcher_factory.h" | 42 #include "content/test/test_url_fetcher_factory.h" |
43 #include "grit/generated_resources.h" | 43 #include "grit/generated_resources.h" |
44 #include "ipc/ipc_test_sink.h" | 44 #include "ipc/ipc_test_sink.h" |
45 #include "testing/gmock/include/gmock/gmock.h" | 45 #include "testing/gmock/include/gmock/gmock.h" |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 // The infobars that have been removed. | 259 // The infobars that have been removed. |
260 // WARNING: the pointers point to deleted objects, use only for comparison. | 260 // WARNING: the pointers point to deleted objects, use only for comparison. |
261 std::set<InfoBarDelegate*> removed_infobars_; | 261 std::set<InfoBarDelegate*> removed_infobars_; |
262 | 262 |
263 DISALLOW_COPY_AND_ASSIGN(TranslateManagerTest); | 263 DISALLOW_COPY_AND_ASSIGN(TranslateManagerTest); |
264 }; | 264 }; |
265 | 265 |
266 // An observer that keeps track of whether a navigation entry was committed. | 266 // An observer that keeps track of whether a navigation entry was committed. |
267 class NavEntryCommittedObserver : public content::NotificationObserver { | 267 class NavEntryCommittedObserver : public content::NotificationObserver { |
268 public: | 268 public: |
269 explicit NavEntryCommittedObserver(TabContents* tab_contents) { | 269 explicit NavEntryCommittedObserver(WebContents* web_contents) { |
270 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, | 270 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
271 content::Source<NavigationController>( | 271 content::Source<NavigationController>( |
272 &tab_contents->GetController())); | 272 &web_contents->GetController())); |
273 } | 273 } |
274 | 274 |
275 virtual void Observe(int type, | 275 virtual void Observe(int type, |
276 const content::NotificationSource& source, | 276 const content::NotificationSource& source, |
277 const content::NotificationDetails& details) { | 277 const content::NotificationDetails& details) { |
278 DCHECK(type == content::NOTIFICATION_NAV_ENTRY_COMMITTED); | 278 DCHECK(type == content::NOTIFICATION_NAV_ENTRY_COMMITTED); |
279 details_ = | 279 details_ = |
280 *(content::Details<content::LoadCommittedDetails>(details).ptr()); | 280 *(content::Details<content::LoadCommittedDetails>(details).ptr()); |
281 } | 281 } |
282 | 282 |
(...skipping 1147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1430 NULL); | 1430 NULL); |
1431 // Now simulate the URL fetch. | 1431 // Now simulate the URL fetch. |
1432 SimulateTranslateScriptURLFetch(true); | 1432 SimulateTranslateScriptURLFetch(true); |
1433 // Now the message should have been sent. | 1433 // Now the message should have been sent. |
1434 int page_id = 0; | 1434 int page_id = 0; |
1435 std::string original_lang, target_lang; | 1435 std::string original_lang, target_lang; |
1436 EXPECT_TRUE(GetTranslateMessage(&page_id, &original_lang, &target_lang)); | 1436 EXPECT_TRUE(GetTranslateMessage(&page_id, &original_lang, &target_lang)); |
1437 EXPECT_EQ("es", original_lang); | 1437 EXPECT_EQ("es", original_lang); |
1438 EXPECT_EQ("en", target_lang); | 1438 EXPECT_EQ("en", target_lang); |
1439 } | 1439 } |
OLD | NEW |