Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chrome / browser / translate / translate_manager_browsertest.cc
blob7dab3efe9ecf711e9430195186d1e6b442dd3d9f
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
3 // found in the LICENSE file.
5 #include "components/translate/core/browser/translate_manager.h"
7 #include "base/memory/scoped_ptr.h"
8 #include "chrome/browser/chrome_notification_types.h"
9 #include "chrome/browser/prefs/session_startup_pref.h"
10 #include "chrome/browser/translate/chrome_translate_client.h"
11 #include "chrome/browser/translate/cld_data_harness.h"
12 #include "chrome/browser/translate/cld_data_harness_factory.h"
13 #include "chrome/browser/ui/browser.h"
14 #include "chrome/browser/ui/tabs/tab_strip_model.h"
15 #include "chrome/test/base/in_process_browser_test.h"
16 #include "chrome/test/base/ui_test_utils.h"
17 #include "components/translate/core/common/language_detection_details.h"
18 #include "url/gurl.h"
20 class TranslateManagerBrowserTest : public InProcessBrowserTest {};
22 // Test is flaky on Win http://crbug.com/166334
23 #if defined(OS_WIN)
24 #define MAYBE_PRE_TranslateSessionRestore DISABLED_PRE_TranslateSessionRestore
25 #else
26 #define MAYBE_PRE_TranslateSessionRestore PRE_TranslateSessionRestore
27 #endif
28 // Test that session restore restores the translate infobar and other translate
29 // settings.
30 IN_PROC_BROWSER_TEST_F(TranslateManagerBrowserTest,
31 MAYBE_PRE_TranslateSessionRestore) {
32 scoped_ptr<test::CldDataHarness> cld_data_harness =
33 test::CldDataHarnessFactory::Get()->CreateCldDataHarness();
34 ASSERT_NO_FATAL_FAILURE(cld_data_harness->Init());
35 SessionStartupPref pref(SessionStartupPref::LAST);
36 SessionStartupPref::SetStartupPref(browser()->profile(), pref);
38 content::WebContents* current_web_contents =
39 browser()->tab_strip_model()->GetActiveWebContents();
40 ChromeTranslateClient* chrome_translate_client =
41 ChromeTranslateClient::FromWebContents(current_web_contents);
42 content::Source<content::WebContents> source(current_web_contents);
44 ui_test_utils::WindowedNotificationObserverWithDetails<
45 translate::LanguageDetectionDetails>
46 fr_language_detected_signal(chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED,
47 source);
49 GURL french_url = ui_test_utils::GetTestUrl(
50 base::FilePath(), base::FilePath(FILE_PATH_LITERAL("french_page.html")));
51 ui_test_utils::NavigateToURL(browser(), french_url);
52 fr_language_detected_signal.Wait();
53 translate::LanguageDetectionDetails details;
54 EXPECT_TRUE(fr_language_detected_signal.GetDetailsFor(
55 source.map_key(), &details));
56 EXPECT_EQ("fr", details.adopted_language);
57 EXPECT_EQ("fr",
58 chrome_translate_client->GetLanguageState().original_language());
61 #if defined (OS_WIN)
62 #define MAYBE_TranslateSessionRestore DISABLED_TranslateSessionRestore
63 #else
64 #define MAYBE_TranslateSessionRestore TranslateSessionRestore
65 #endif
66 IN_PROC_BROWSER_TEST_F(TranslateManagerBrowserTest,
67 MAYBE_TranslateSessionRestore) {
68 scoped_ptr<test::CldDataHarness> cld_data_harness =
69 test::CldDataHarnessFactory::Get()->CreateCldDataHarness();
70 ASSERT_NO_FATAL_FAILURE(cld_data_harness->Init());
71 content::WebContents* current_web_contents =
72 browser()->tab_strip_model()->GetActiveWebContents();
73 content::Source<content::WebContents> source(current_web_contents);
75 ui_test_utils::WindowedNotificationObserverWithDetails<
76 translate::LanguageDetectionDetails>
77 fr_language_detected_signal(chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED,
78 source);
79 fr_language_detected_signal.Wait();