OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/ui/views/translate/translate_bubble_view.h" | 5 #include "chrome/browser/ui/views/translate/translate_bubble_view.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "chrome/browser/chrome_notification_types.h" | 11 #include "chrome/browser/chrome_notification_types.h" |
12 #include "chrome/browser/translate/chrome_translate_client.h" | 12 #include "chrome/browser/translate/chrome_translate_client.h" |
13 #include "chrome/browser/translate/cld_data_harness.h" | |
14 #include "chrome/browser/translate/cld_data_harness_factory.h" | |
15 #include "chrome/browser/ui/browser.h" | 13 #include "chrome/browser/ui/browser.h" |
16 #include "chrome/browser/ui/browser_commands.h" | 14 #include "chrome/browser/ui/browser_commands.h" |
17 #include "chrome/browser/ui/browser_tabstrip.h" | 15 #include "chrome/browser/ui/browser_tabstrip.h" |
18 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 16 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
19 #include "chrome/common/chrome_switches.h" | 17 #include "chrome/common/chrome_switches.h" |
20 #include "chrome/test/base/in_process_browser_test.h" | 18 #include "chrome/test/base/in_process_browser_test.h" |
21 #include "chrome/test/base/ui_test_utils.h" | 19 #include "chrome/test/base/ui_test_utils.h" |
22 #include "components/translate/core/common/language_detection_details.h" | 20 #include "components/translate/core/common/language_detection_details.h" |
23 #include "content/public/browser/notification_details.h" | 21 #include "content/public/browser/notification_details.h" |
24 | 22 |
25 class TranslateBubbleViewBrowserTest : public InProcessBrowserTest { | 23 class TranslateBubbleViewBrowserTest : public InProcessBrowserTest { |
26 public: | 24 public: |
27 TranslateBubbleViewBrowserTest(): | |
28 cld_data_harness( | |
29 test::CldDataHarnessFactory::Get()->CreateCldDataHarness()) {} | |
30 ~TranslateBubbleViewBrowserTest() override {} | 25 ~TranslateBubbleViewBrowserTest() override {} |
31 void SetUpOnMainThread() override { | 26 void SetUpOnMainThread() override { |
32 // We can't Init() until PathService has been initialized. This happens | |
33 // very late in the test fixture setup process. | |
34 cld_data_harness->Init(); | |
35 InProcessBrowserTest::SetUpOnMainThread(); | 27 InProcessBrowserTest::SetUpOnMainThread(); |
36 } | 28 } |
37 | 29 |
38 private: | 30 private: |
39 std::unique_ptr<test::CldDataHarness> cld_data_harness; | |
40 DISALLOW_COPY_AND_ASSIGN(TranslateBubbleViewBrowserTest); | 31 DISALLOW_COPY_AND_ASSIGN(TranslateBubbleViewBrowserTest); |
41 }; | 32 }; |
42 | 33 |
43 // Flaky: crbug.com/394066 | 34 // Flaky: crbug.com/394066 |
44 IN_PROC_BROWSER_TEST_F(TranslateBubbleViewBrowserTest, | 35 IN_PROC_BROWSER_TEST_F(TranslateBubbleViewBrowserTest, |
45 DISABLED_CloseBrowserWithoutTranslating) { | 36 DISABLED_CloseBrowserWithoutTranslating) { |
46 EXPECT_FALSE(TranslateBubbleView::GetCurrentBubble()); | 37 EXPECT_FALSE(TranslateBubbleView::GetCurrentBubble()); |
47 | 38 |
48 // Show a French page and wait until the bubble is shown. | 39 // Show a French page and wait until the bubble is shown. |
49 content::WebContents* current_web_contents = | 40 content::WebContents* current_web_contents = |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 chrome::CloseWebContents(browser(), web_contents, false); | 104 chrome::CloseWebContents(browser(), web_contents, false); |
114 EXPECT_EQ(active_index, browser()->tab_strip_model()->active_index()); | 105 EXPECT_EQ(active_index, browser()->tab_strip_model()->active_index()); |
115 EXPECT_EQ(1, browser()->tab_strip_model()->count()); | 106 EXPECT_EQ(1, browser()->tab_strip_model()->count()); |
116 EXPECT_FALSE(TranslateBubbleView::GetCurrentBubble()); | 107 EXPECT_FALSE(TranslateBubbleView::GetCurrentBubble()); |
117 | 108 |
118 // Close the last tab. | 109 // Close the last tab. |
119 chrome::CloseWebContents(browser(), | 110 chrome::CloseWebContents(browser(), |
120 browser()->tab_strip_model()->GetActiveWebContents(), | 111 browser()->tab_strip_model()->GetActiveWebContents(), |
121 false); | 112 false); |
122 } | 113 } |
OLD | NEW |