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

Side by Side Diff: chrome/browser/translate/translate_manager_unittest.cc

Issue 5519016: Add a new GetInstance() method for singleton classes used in chrome/browser files. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 10 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/renderer_host/test/test_render_view_host.h" 5 #include "chrome/browser/renderer_host/test/test_render_view_host.h"
6 6
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "chrome/app/chrome_command_ids.h" 8 #include "chrome/app/chrome_command_ids.h"
9 #include "chrome/browser/prefs/pref_service.h" 9 #include "chrome/browser/prefs/pref_service.h"
10 #include "chrome/browser/prefs/pref_change_registrar.h" 10 #include "chrome/browser/prefs/pref_change_registrar.h"
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 bool InfoBarRemoved() { 114 bool InfoBarRemoved() {
115 return !removed_infobars_.empty(); 115 return !removed_infobars_.empty();
116 } 116 }
117 117
118 // Clears the list of stored removed infobars. 118 // Clears the list of stored removed infobars.
119 void ClearRemovedInfoBars() { 119 void ClearRemovedInfoBars() {
120 removed_infobars_.clear(); 120 removed_infobars_.clear();
121 } 121 }
122 122
123 void ExpireTranslateScriptImmediately() { 123 void ExpireTranslateScriptImmediately() {
124 Singleton<TranslateManager>::get()-> 124 TranslateManager::GetInstance()->set_translate_script_expiration_delay(0);
125 set_translate_script_expiration_delay(0);
126 } 125 }
127 126
128 // If there is 1 infobar and it is a translate infobar, deny translation and 127 // If there is 1 infobar and it is a translate infobar, deny translation and
129 // returns true. Returns false otherwise. 128 // returns true. Returns false otherwise.
130 bool DenyTranslation() { 129 bool DenyTranslation() {
131 TranslateInfoBarDelegate* infobar = GetTranslateInfoBar(); 130 TranslateInfoBarDelegate* infobar = GetTranslateInfoBar();
132 if (!infobar) 131 if (!infobar)
133 return false; 132 return false;
134 infobar->TranslationDeclined(); 133 infobar->TranslationDeclined();
135 contents()->RemoveInfoBar(infobar); 134 contents()->RemoveInfoBar(infobar);
(...skipping 12 matching lines...) Expand all
148 URLFetcher::set_factory(&url_fetcher_factory_); 147 URLFetcher::set_factory(&url_fetcher_factory_);
149 148
150 // Access the TranslateManager singleton so it is created before we call 149 // Access the TranslateManager singleton so it is created before we call
151 // RenderViewHostTestHarness::SetUp() to match what's done in Chrome, where 150 // RenderViewHostTestHarness::SetUp() to match what's done in Chrome, where
152 // the TranslateManager is created before the TabContents. This matters as 151 // the TranslateManager is created before the TabContents. This matters as
153 // they both register for similar events and we want the notifications to 152 // they both register for similar events and we want the notifications to
154 // happen in the same sequence (TranslateManager first, TabContents second). 153 // happen in the same sequence (TranslateManager first, TabContents second).
155 // Also clears the translate script so it is fetched everytime and sets the 154 // Also clears the translate script so it is fetched everytime and sets the
156 // expiration delay to a large value by default (in case it was zeroed in 155 // expiration delay to a large value by default (in case it was zeroed in
157 // a previous test). 156 // a previous test).
158 Singleton<TranslateManager>::get()->ClearTranslateScript(); 157 TranslateManager::GetInstance()->ClearTranslateScript();
159 Singleton<TranslateManager>::get()-> 158 TranslateManager::GetInstance()->
160 set_translate_script_expiration_delay(60 * 60 * 1000); 159 set_translate_script_expiration_delay(60 * 60 * 1000);
161 160
162 RenderViewHostTestHarness::SetUp(); 161 RenderViewHostTestHarness::SetUp();
163 162
164 notification_registrar_.Add( 163 notification_registrar_.Add(
165 this, 164 this,
166 NotificationType::TAB_CONTENTS_INFOBAR_REMOVED, 165 NotificationType::TAB_CONTENTS_INFOBAR_REMOVED,
167 Source<TabContents>(contents())); 166 Source<TabContents>(contents()));
168 } 167 }
169 168
(...skipping 1054 matching lines...) Expand 10 before | Expand all | Expand 10 after
1224 NULL); 1223 NULL);
1225 // Now simulate the URL fetch. 1224 // Now simulate the URL fetch.
1226 SimulateURLFetch(true); 1225 SimulateURLFetch(true);
1227 // Now the message should have been sent. 1226 // Now the message should have been sent.
1228 int page_id = 0; 1227 int page_id = 0;
1229 std::string original_lang, target_lang; 1228 std::string original_lang, target_lang;
1230 EXPECT_TRUE(GetTranslateMessage(&page_id, &original_lang, &target_lang)); 1229 EXPECT_TRUE(GetTranslateMessage(&page_id, &original_lang, &target_lang));
1231 EXPECT_EQ("es", original_lang); 1230 EXPECT_EQ("es", original_lang);
1232 EXPECT_EQ("en", target_lang); 1231 EXPECT_EQ("en", target_lang);
1233 } 1232 }
OLDNEW
« no previous file with comments | « chrome/browser/translate/translate_manager.cc ('k') | chrome/browser/ui/app_modal_dialogs/app_modal_dialog.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698