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