OLD | NEW |
1 // Copyright (c) 2011 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 | 5 |
6 #include <algorithm> | 6 #include <algorithm> |
7 #include <set> | 7 #include <set> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 #include "testing/gmock/include/gmock/gmock.h" | 39 #include "testing/gmock/include/gmock/gmock.h" |
40 #include "third_party/WebKit/Source/WebKit/chromium/public/WebContextMenuData.h" | 40 #include "third_party/WebKit/Source/WebKit/chromium/public/WebContextMenuData.h" |
41 #include "third_party/cld/languages/public/languages.h" | 41 #include "third_party/cld/languages/public/languages.h" |
42 | 42 |
43 #if defined(USE_WEBKIT_COMPOSITOR) | 43 #if defined(USE_WEBKIT_COMPOSITOR) |
44 #include "content/test/render_view_test.h" | 44 #include "content/test/render_view_test.h" |
45 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" | 45 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" |
46 #endif | 46 #endif |
47 | 47 |
48 using content::BrowserThread; | 48 using content::BrowserThread; |
| 49 using content::NavigationController; |
49 using content::WebContents; | 50 using content::WebContents; |
50 using testing::_; | 51 using testing::_; |
51 using testing::Pointee; | 52 using testing::Pointee; |
52 using testing::Property; | 53 using testing::Property; |
53 using WebKit::WebContextMenuData; | 54 using WebKit::WebContextMenuData; |
54 | 55 |
55 class TranslateManagerTest : public TabContentsWrapperTestHarness, | 56 class TranslateManagerTest : public TabContentsWrapperTestHarness, |
56 public content::NotificationObserver { | 57 public content::NotificationObserver { |
57 public: | 58 public: |
58 TranslateManagerTest() | 59 TranslateManagerTest() |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 std::set<InfoBarDelegate*> removed_infobars_; | 263 std::set<InfoBarDelegate*> removed_infobars_; |
263 | 264 |
264 DISALLOW_COPY_AND_ASSIGN(TranslateManagerTest); | 265 DISALLOW_COPY_AND_ASSIGN(TranslateManagerTest); |
265 }; | 266 }; |
266 | 267 |
267 // An observer that keeps track of whether a navigation entry was committed. | 268 // An observer that keeps track of whether a navigation entry was committed. |
268 class NavEntryCommittedObserver : public content::NotificationObserver { | 269 class NavEntryCommittedObserver : public content::NotificationObserver { |
269 public: | 270 public: |
270 explicit NavEntryCommittedObserver(TabContents* tab_contents) { | 271 explicit NavEntryCommittedObserver(TabContents* tab_contents) { |
271 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, | 272 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
272 content::Source<content::NavigationController>( | 273 content::Source<NavigationController>( |
273 &tab_contents->GetController())); | 274 &tab_contents->GetController())); |
274 } | 275 } |
275 | 276 |
276 virtual void Observe(int type, | 277 virtual void Observe(int type, |
277 const content::NotificationSource& source, | 278 const content::NotificationSource& source, |
278 const content::NotificationDetails& details) { | 279 const content::NotificationDetails& details) { |
279 DCHECK(type == content::NOTIFICATION_NAV_ENTRY_COMMITTED); | 280 DCHECK(type == content::NOTIFICATION_NAV_ENTRY_COMMITTED); |
280 details_ = | 281 details_ = |
281 *(content::Details<content::LoadCommittedDetails>(details).ptr()); | 282 *(content::Details<content::LoadCommittedDetails>(details).ptr()); |
282 } | 283 } |
(...skipping 1083 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1366 NULL); | 1367 NULL); |
1367 // Now simulate the URL fetch. | 1368 // Now simulate the URL fetch. |
1368 SimulateTranslateScriptURLFetch(true); | 1369 SimulateTranslateScriptURLFetch(true); |
1369 // Now the message should have been sent. | 1370 // Now the message should have been sent. |
1370 int page_id = 0; | 1371 int page_id = 0; |
1371 std::string original_lang, target_lang; | 1372 std::string original_lang, target_lang; |
1372 EXPECT_TRUE(GetTranslateMessage(&page_id, &original_lang, &target_lang)); | 1373 EXPECT_TRUE(GetTranslateMessage(&page_id, &original_lang, &target_lang)); |
1373 EXPECT_EQ("es", original_lang); | 1374 EXPECT_EQ("es", original_lang); |
1374 EXPECT_EQ("en", target_lang); | 1375 EXPECT_EQ("en", target_lang); |
1375 } | 1376 } |
OLD | NEW |