Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(122)

Side by Side Diff: components/translate/core/browser/translate_ui_delegate_unittest.cc

Issue 2913593002: Implementation of translation event logging. (Closed)
Patch Set: fix Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "components/translate/core/browser/translate_ui_delegate.h" 5 #include "components/translate/core/browser/translate_ui_delegate.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
11 #include "base/strings/stringprintf.h" 11 #include "base/strings/stringprintf.h"
12 #include "build/build_config.h" 12 #include "build/build_config.h"
13 #include "components/infobars/core/infobar.h" 13 #include "components/infobars/core/infobar.h"
14 #include "components/metrics/proto/translate_event.pb.h"
14 #include "components/pref_registry/pref_registry_syncable.h" 15 #include "components/pref_registry/pref_registry_syncable.h"
15 #include "components/sync_preferences/testing_pref_service_syncable.h" 16 #include "components/sync_preferences/testing_pref_service_syncable.h"
16 #include "components/translate/core/browser/mock_translate_driver.h" 17 #include "components/translate/core/browser/mock_translate_driver.h"
17 #include "components/translate/core/browser/mock_translate_ranker.h" 18 #include "components/translate/core/browser/mock_translate_ranker.h"
18 #include "components/translate/core/browser/translate_client.h" 19 #include "components/translate/core/browser/translate_client.h"
19 #include "components/translate/core/browser/translate_infobar_delegate.h" 20 #include "components/translate/core/browser/translate_infobar_delegate.h"
20 #include "components/translate/core/browser/translate_manager.h" 21 #include "components/translate/core/browser/translate_manager.h"
21 #include "components/translate/core/browser/translate_prefs.h" 22 #include "components/translate/core/browser/translate_prefs.h"
22 #include "components/variations/variations_associated_data.h" 23 #include "components/variations/variations_associated_data.h"
23 #include "testing/gmock/include/gmock/gmock.h" 24 #include "testing/gmock/include/gmock/gmock.h"
(...skipping 22 matching lines...) Expand all
46 PrefService* GetPrefs() { return prefs_; } 47 PrefService* GetPrefs() { return prefs_; }
47 48
48 std::unique_ptr<TranslatePrefs> GetTranslatePrefs() { 49 std::unique_ptr<TranslatePrefs> GetTranslatePrefs() {
49 return base::MakeUnique<TranslatePrefs>(prefs_, "intl.accept_languages", 50 return base::MakeUnique<TranslatePrefs>(prefs_, "intl.accept_languages",
50 preferred_languages_prefs); 51 preferred_languages_prefs);
51 } 52 }
52 53
53 MOCK_METHOD0(GetTranslateAcceptLanguages, TranslateAcceptLanguages*()); 54 MOCK_METHOD0(GetTranslateAcceptLanguages, TranslateAcceptLanguages*());
54 MOCK_CONST_METHOD0(GetInfobarIconID, int()); 55 MOCK_CONST_METHOD0(GetInfobarIconID, int());
55 56
57 MOCK_METHOD1(RecordTranslateEvent, void(const metrics::TranslateEventProto&));
58
56 MOCK_CONST_METHOD1(CreateInfoBarMock, 59 MOCK_CONST_METHOD1(CreateInfoBarMock,
57 infobars::InfoBar*(TranslateInfoBarDelegate*)); 60 infobars::InfoBar*(TranslateInfoBarDelegate*));
58 std::unique_ptr<infobars::InfoBar> CreateInfoBar( 61 std::unique_ptr<infobars::InfoBar> CreateInfoBar(
59 std::unique_ptr<TranslateInfoBarDelegate> delegate) const { 62 std::unique_ptr<TranslateInfoBarDelegate> delegate) const {
60 return base::WrapUnique(CreateInfoBarMock(std::move(delegate).get())); 63 return base::WrapUnique(CreateInfoBarMock(std::move(delegate).get()));
61 } 64 }
62 65
63 MOCK_METHOD5(ShowTranslateUI, 66 MOCK_METHOD5(ShowTranslateUI,
64 void(translate::TranslateStep, 67 void(translate::TranslateStep,
65 const std::string&, 68 const std::string&,
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 prefs->IncrementTranslationAcceptedCount("ar"); 203 prefs->IncrementTranslationAcceptedCount("ar");
201 204
202 EXPECT_FALSE(delegate_->ShouldAlwaysTranslateBeCheckedByDefault()); 205 EXPECT_FALSE(delegate_->ShouldAlwaysTranslateBeCheckedByDefault());
203 } 206 }
204 207
205 // TODO(ftang) Currently this file only test TranslationDeclined(), we 208 // TODO(ftang) Currently this file only test TranslationDeclined(), we
206 // need to add the test for other functions soon to increase the test 209 // need to add the test for other functions soon to increase the test
207 // coverage. 210 // coverage.
208 211
209 } // namespace translate 212 } // namespace translate
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698