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