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 #include "components/translate/core/browser/translate_manager.h" | 5 #include "components/translate/core/browser/translate_manager.h" |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "chrome/browser/chrome_notification_types.h" | 8 #include "chrome/browser/chrome_notification_types.h" |
9 #include "chrome/browser/prefs/session_startup_pref.h" | 9 #include "chrome/browser/prefs/session_startup_pref.h" |
10 #include "chrome/browser/translate/chrome_translate_client.h" | 10 #include "chrome/browser/translate/chrome_translate_client.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 SessionStartupPref pref(SessionStartupPref::LAST); | 34 SessionStartupPref pref(SessionStartupPref::LAST); |
35 SessionStartupPref::SetStartupPref(browser()->profile(), pref); | 35 SessionStartupPref::SetStartupPref(browser()->profile(), pref); |
36 | 36 |
37 content::WebContents* current_web_contents = | 37 content::WebContents* current_web_contents = |
38 browser()->tab_strip_model()->GetActiveWebContents(); | 38 browser()->tab_strip_model()->GetActiveWebContents(); |
39 ChromeTranslateClient* chrome_translate_client = | 39 ChromeTranslateClient* chrome_translate_client = |
40 ChromeTranslateClient::FromWebContents(current_web_contents); | 40 ChromeTranslateClient::FromWebContents(current_web_contents); |
41 content::Source<content::WebContents> source(current_web_contents); | 41 content::Source<content::WebContents> source(current_web_contents); |
42 | 42 |
43 ui_test_utils::WindowedNotificationObserverWithDetails< | 43 ui_test_utils::WindowedNotificationObserverWithDetails< |
44 LanguageDetectionDetails> | 44 translate::LanguageDetectionDetails> |
45 fr_language_detected_signal(chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, | 45 fr_language_detected_signal(chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, |
46 source); | 46 source); |
47 | 47 |
48 GURL french_url = ui_test_utils::GetTestUrl( | 48 GURL french_url = ui_test_utils::GetTestUrl( |
49 base::FilePath(), base::FilePath(FILE_PATH_LITERAL("french_page.html"))); | 49 base::FilePath(), base::FilePath(FILE_PATH_LITERAL("french_page.html"))); |
50 ui_test_utils::NavigateToURL(browser(), french_url); | 50 ui_test_utils::NavigateToURL(browser(), french_url); |
51 fr_language_detected_signal.Wait(); | 51 fr_language_detected_signal.Wait(); |
52 LanguageDetectionDetails details; | 52 translate::LanguageDetectionDetails details; |
53 EXPECT_TRUE(fr_language_detected_signal.GetDetailsFor( | 53 EXPECT_TRUE(fr_language_detected_signal.GetDetailsFor( |
54 source.map_key(), &details)); | 54 source.map_key(), &details)); |
55 EXPECT_EQ("fr", details.adopted_language); | 55 EXPECT_EQ("fr", details.adopted_language); |
56 EXPECT_EQ("fr", | 56 EXPECT_EQ("fr", |
57 chrome_translate_client->GetLanguageState().original_language()); | 57 chrome_translate_client->GetLanguageState().original_language()); |
58 } | 58 } |
59 | 59 |
60 #if defined (OS_WIN) | 60 #if defined (OS_WIN) |
61 #define MAYBE_TranslateSessionRestore DISABLED_TranslateSessionRestore | 61 #define MAYBE_TranslateSessionRestore DISABLED_TranslateSessionRestore |
62 #else | 62 #else |
63 #define MAYBE_TranslateSessionRestore TranslateSessionRestore | 63 #define MAYBE_TranslateSessionRestore TranslateSessionRestore |
64 #endif | 64 #endif |
65 IN_PROC_BROWSER_TEST_F(TranslateManagerBrowserTest, | 65 IN_PROC_BROWSER_TEST_F(TranslateManagerBrowserTest, |
66 MAYBE_TranslateSessionRestore) { | 66 MAYBE_TranslateSessionRestore) { |
67 scoped_ptr<test::CldDataHarness> cld_data_harness = | 67 scoped_ptr<test::CldDataHarness> cld_data_harness = |
68 test::CreateCldDataHarness(); | 68 test::CreateCldDataHarness(); |
69 ASSERT_NO_FATAL_FAILURE(cld_data_harness->Init()); | 69 ASSERT_NO_FATAL_FAILURE(cld_data_harness->Init()); |
70 content::WebContents* current_web_contents = | 70 content::WebContents* current_web_contents = |
71 browser()->tab_strip_model()->GetActiveWebContents(); | 71 browser()->tab_strip_model()->GetActiveWebContents(); |
72 content::Source<content::WebContents> source(current_web_contents); | 72 content::Source<content::WebContents> source(current_web_contents); |
73 | 73 |
74 ui_test_utils::WindowedNotificationObserverWithDetails< | 74 ui_test_utils::WindowedNotificationObserverWithDetails< |
75 LanguageDetectionDetails> | 75 translate::LanguageDetectionDetails> |
76 fr_language_detected_signal(chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, | 76 fr_language_detected_signal(chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, |
77 source); | 77 source); |
78 fr_language_detected_signal.Wait(); | 78 fr_language_detected_signal.Wait(); |
79 } | 79 } |
OLD | NEW |