| 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 "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
| 11 #include "chrome/browser/translate/chrome_translate_client.h" | |
| 12 #include "chrome/browser/translate/cld_data_harness.h" | 11 #include "chrome/browser/translate/cld_data_harness.h" |
| 13 #include "chrome/browser/translate/cld_data_harness_factory.h" | 12 #include "chrome/browser/translate/cld_data_harness_factory.h" |
| 14 #include "chrome/browser/ui/browser.h" | 13 #include "chrome/browser/ui/browser.h" |
| 15 #include "chrome/browser/ui/browser_commands.h" | 14 #include "chrome/browser/ui/browser_commands.h" |
| 16 #include "chrome/browser/ui/browser_tabstrip.h" | 15 #include "chrome/browser/ui/browser_tabstrip.h" |
| 17 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 16 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 18 #include "chrome/common/chrome_switches.h" | 17 #include "chrome/common/chrome_switches.h" |
| 19 #include "chrome/test/base/in_process_browser_test.h" | 18 #include "chrome/test/base/in_process_browser_test.h" |
| 20 #include "chrome/test/base/ui_test_utils.h" | 19 #include "chrome/test/base/ui_test_utils.h" |
| 21 #include "components/translate/core/common/language_detection_details.h" | 20 #include "components/translate/core/common/language_detection_details.h" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 int active_index = browser()->tab_strip_model()->active_index(); | 94 int active_index = browser()->tab_strip_model()->active_index(); |
| 96 | 95 |
| 97 // Open another tab to load a French page on background. | 96 // Open another tab to load a French page on background. |
| 98 int french_index = active_index + 1; | 97 int french_index = active_index + 1; |
| 99 GURL french_url = ui_test_utils::GetTestUrl( | 98 GURL french_url = ui_test_utils::GetTestUrl( |
| 100 base::FilePath(), base::FilePath(FILE_PATH_LITERAL("french_page.html"))); | 99 base::FilePath(), base::FilePath(FILE_PATH_LITERAL("french_page.html"))); |
| 101 chrome::AddTabAt(browser(), french_url, french_index, false); | 100 chrome::AddTabAt(browser(), french_url, french_index, false); |
| 102 EXPECT_EQ(active_index, browser()->tab_strip_model()->active_index()); | 101 EXPECT_EQ(active_index, browser()->tab_strip_model()->active_index()); |
| 103 EXPECT_EQ(2, browser()->tab_strip_model()->count()); | 102 EXPECT_EQ(2, browser()->tab_strip_model()->count()); |
| 104 | 103 |
| 104 // Wait until the language is detected. |
| 105 content::WebContents* web_contents = | 105 content::WebContents* web_contents = |
| 106 browser()->tab_strip_model()->GetWebContentsAt(french_index); | 106 browser()->tab_strip_model()->GetWebContentsAt(french_index); |
| 107 content::Source<content::WebContents> source(web_contents); |
| 108 ui_test_utils::WindowedNotificationObserverWithDetails< |
| 109 translate::LanguageDetectionDetails> |
| 110 fr_language_detected_signal(chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, |
| 111 source); |
| 112 fr_language_detected_signal.Wait(); |
| 107 | 113 |
| 108 // The bubble is not shown because the tab is not activated. | 114 // The bubble is not shown because the tab is not activated. |
| 109 EXPECT_FALSE(TranslateBubbleView::GetCurrentBubble()); | 115 EXPECT_FALSE(TranslateBubbleView::GetCurrentBubble()); |
| 110 | 116 |
| 111 // Close the French page tab immediately. | 117 // Close the French page tab immediately. |
| 112 chrome::CloseWebContents(browser(), web_contents, false); | 118 chrome::CloseWebContents(browser(), web_contents, false); |
| 113 EXPECT_EQ(active_index, browser()->tab_strip_model()->active_index()); | 119 EXPECT_EQ(active_index, browser()->tab_strip_model()->active_index()); |
| 114 EXPECT_EQ(1, browser()->tab_strip_model()->count()); | 120 EXPECT_EQ(1, browser()->tab_strip_model()->count()); |
| 115 EXPECT_FALSE(TranslateBubbleView::GetCurrentBubble()); | 121 EXPECT_FALSE(TranslateBubbleView::GetCurrentBubble()); |
| 116 | 122 |
| 117 // Close the last tab. | 123 // Close the last tab. |
| 118 chrome::CloseWebContents(browser(), | 124 chrome::CloseWebContents(browser(), |
| 119 browser()->tab_strip_model()->GetActiveWebContents(), | 125 browser()->tab_strip_model()->GetActiveWebContents(), |
| 120 false); | 126 false); |
| 121 } | 127 } |
| OLD | NEW |