| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #import <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
| 6 | 6 |
| 7 #import "base/mac/scoped_nsobject.h" | 7 #import "base/mac/scoped_nsobject.h" |
| 8 #import "base/strings/string_util.h" | 8 #import "base/strings/string_util.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #import "chrome/app/chrome_command_ids.h" // For translate menu command ids. | 10 #import "chrome/app/chrome_command_ids.h" // For translate menu command ids. |
| 11 #include "chrome/browser/infobars/infobar_service.h" | 11 #include "chrome/browser/infobars/infobar_service.h" |
| 12 #import "chrome/browser/translate/translate_infobar_delegate.h" | |
| 13 #import "chrome/browser/translate/translate_tab_helper.h" | 12 #import "chrome/browser/translate/translate_tab_helper.h" |
| 14 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h" | 13 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h" |
| 15 #import "chrome/browser/ui/cocoa/infobars/before_translate_infobar_controller.h" | 14 #import "chrome/browser/ui/cocoa/infobars/before_translate_infobar_controller.h" |
| 16 #import "chrome/browser/ui/cocoa/infobars/infobar_cocoa.h" | 15 #import "chrome/browser/ui/cocoa/infobars/infobar_cocoa.h" |
| 17 #import "chrome/browser/ui/cocoa/infobars/translate_infobar_base.h" | 16 #import "chrome/browser/ui/cocoa/infobars/translate_infobar_base.h" |
| 18 #include "chrome/test/base/testing_profile.h" | 17 #include "chrome/test/base/testing_profile.h" |
| 18 #import "components/translate/core/browser/options_menu_model.h" |
| 19 #import "components/translate/core/browser/translate_infobar_delegate.h" |
| 19 #include "components/translate/core/browser/translate_language_list.h" | 20 #include "components/translate/core/browser/translate_language_list.h" |
| 20 #include "components/translate/core/browser/translate_manager.h" | 21 #include "components/translate/core/browser/translate_manager.h" |
| 21 #import "content/public/browser/web_contents.h" | 22 #import "content/public/browser/web_contents.h" |
| 22 #include "ipc/ipc_message.h" | 23 #include "ipc/ipc_message.h" |
| 23 #import "testing/gmock/include/gmock/gmock.h" | 24 #import "testing/gmock/include/gmock/gmock.h" |
| 24 #import "testing/gtest/include/gtest/gtest.h" | 25 #import "testing/gtest/include/gtest/gtest.h" |
| 25 #import "testing/platform_test.h" | 26 #import "testing/platform_test.h" |
| 26 | 27 |
| 27 using content::WebContents; | 28 using content::WebContents; |
| 28 | 29 |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 | 197 |
| 197 { | 198 { |
| 198 EXPECT_CALL(*infobar_delegate(), ToggleSiteBlacklist()) | 199 EXPECT_CALL(*infobar_delegate(), ToggleSiteBlacklist()) |
| 199 .Times(1); | 200 .Times(1); |
| 200 [infobar_controller_ optionsMenuChanged:neverTranslateSiteItem]; | 201 [infobar_controller_ optionsMenuChanged:neverTranslateSiteItem]; |
| 201 } | 202 } |
| 202 | 203 |
| 203 { | 204 { |
| 204 // Can't mock these effectively, so just check that the tag is set | 205 // Can't mock these effectively, so just check that the tag is set |
| 205 // correctly. | 206 // correctly. |
| 206 EXPECT_EQ(IDC_TRANSLATE_REPORT_BAD_LANGUAGE_DETECTION, | 207 EXPECT_EQ(OptionsMenuModel::kOptionsReportBadDetection, |
| 207 [reportBadLanguageItem tag]); | 208 [reportBadLanguageItem tag]); |
| 208 EXPECT_EQ(IDC_TRANSLATE_OPTIONS_ABOUT, [aboutTranslateItem tag]); | 209 EXPECT_EQ(OptionsMenuModel::kOptionsAboutTranslate, |
| 210 [aboutTranslateItem tag]); |
| 209 } | 211 } |
| 210 } | 212 } |
| 211 | 213 |
| 212 // Check that selecting a new item from the "Source Language" popup in "before | 214 // Check that selecting a new item from the "Source Language" popup in "before |
| 213 // translate" mode doesn't trigger a translation or change state. | 215 // translate" mode doesn't trigger a translation or change state. |
| 214 // http://crbug.com/36666 | 216 // http://crbug.com/36666 |
| 215 TEST_F(TranslationInfoBarTest, Bug36666) { | 217 TEST_F(TranslationInfoBarTest, Bug36666) { |
| 216 CreateInfoBar(translate::TRANSLATE_STEP_BEFORE_TRANSLATE); | 218 CreateInfoBar(translate::TRANSLATE_STEP_BEFORE_TRANSLATE); |
| 217 EXPECT_CALL(*infobar_delegate(), Translate()) | 219 EXPECT_CALL(*infobar_delegate(), Translate()) |
| 218 .Times(0); | 220 .Times(0); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 translate_prefs->ResetTranslationDeniedCount("en"); | 262 translate_prefs->ResetTranslationDeniedCount("en"); |
| 261 for (int i = 0; i < 4; ++i) { | 263 for (int i = 0; i < 4; ++i) { |
| 262 translate_prefs->IncrementTranslationDeniedCount("en"); | 264 translate_prefs->IncrementTranslationDeniedCount("en"); |
| 263 } | 265 } |
| 264 CreateInfoBar(translate::TRANSLATE_STEP_BEFORE_TRANSLATE); | 266 CreateInfoBar(translate::TRANSLATE_STEP_BEFORE_TRANSLATE); |
| 265 BeforeTranslateInfobarController* controller = | 267 BeforeTranslateInfobarController* controller = |
| 266 (BeforeTranslateInfobarController*)infobar_controller_.get(); | 268 (BeforeTranslateInfobarController*)infobar_controller_.get(); |
| 267 EXPECT_TRUE([[controller alwaysTranslateButton] superview] == nil); | 269 EXPECT_TRUE([[controller alwaysTranslateButton] superview] == nil); |
| 268 EXPECT_TRUE([[controller neverTranslateButton] superview] != nil); | 270 EXPECT_TRUE([[controller neverTranslateButton] superview] != nil); |
| 269 } | 271 } |
| OLD | NEW |