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

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

Issue 9977021: Add ExtensionSytem::Get(Profile*) as a wrapper around (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 5
6 #include <algorithm> 6 #include <algorithm>
7 #include <set> 7 #include <set>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/json/json_writer.h" 10 #include "base/json/json_writer.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/stringprintf.h" 12 #include "base/stringprintf.h"
13 #include "base/utf_string_conversions.h" 13 #include "base/utf_string_conversions.h"
14 #include "base/values.h" 14 #include "base/values.h"
15 #include "chrome/app/chrome_command_ids.h" 15 #include "chrome/app/chrome_command_ids.h"
16 #include "chrome/browser/extensions/extension_system_factory.h"
17 #include "chrome/browser/extensions/test_extension_system.h" 16 #include "chrome/browser/extensions/test_extension_system.h"
18 #include "chrome/browser/infobars/infobar.h" 17 #include "chrome/browser/infobars/infobar.h"
19 #include "chrome/browser/infobars/infobar_tab_helper.h" 18 #include "chrome/browser/infobars/infobar_tab_helper.h"
20 #include "chrome/browser/prefs/pref_change_registrar.h" 19 #include "chrome/browser/prefs/pref_change_registrar.h"
21 #include "chrome/browser/prefs/pref_service.h" 20 #include "chrome/browser/prefs/pref_service.h"
22 #include "chrome/browser/tab_contents/render_view_context_menu.h" 21 #include "chrome/browser/tab_contents/render_view_context_menu.h"
23 #include "chrome/browser/translate/translate_infobar_delegate.h" 22 #include "chrome/browser/translate/translate_infobar_delegate.h"
24 #include "chrome/browser/translate/translate_manager.h" 23 #include "chrome/browser/translate/translate_manager.h"
25 #include "chrome/browser/translate/translate_prefs.h" 24 #include "chrome/browser/translate/translate_prefs.h"
26 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 25 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
(...skipping 1316 matching lines...) Expand 10 before | Expand all | Expand 10 after
1343 translate_prefs.ResetTranslationDeniedCount("fr"); 1342 translate_prefs.ResetTranslationDeniedCount("fr");
1344 translate_prefs.ResetTranslationAcceptedCount("de"); 1343 translate_prefs.ResetTranslationAcceptedCount("de");
1345 translate_prefs.ResetTranslationDeniedCount("de"); 1344 translate_prefs.ResetTranslationDeniedCount("de");
1346 1345
1347 // We'll do 4 times in incognito mode first to make sure the button is not 1346 // We'll do 4 times in incognito mode first to make sure the button is not
1348 // shown in that case, then 4 times in normal mode. 1347 // shown in that case, then 4 times in normal mode.
1349 TranslateInfoBarDelegate* infobar; 1348 TranslateInfoBarDelegate* infobar;
1350 TestingProfile* test_profile = 1349 TestingProfile* test_profile =
1351 static_cast<TestingProfile*>(contents()->GetBrowserContext()); 1350 static_cast<TestingProfile*>(contents()->GetBrowserContext());
1352 static_cast<TestExtensionSystem*>( 1351 static_cast<TestExtensionSystem*>(
1353 ExtensionSystemFactory::GetForProfile(test_profile))-> 1352 ExtensionSystem::Get(test_profile))->
1354 CreateExtensionProcessManager(); 1353 CreateExtensionProcessManager();
1355 test_profile->set_incognito(true); 1354 test_profile->set_incognito(true);
1356 for (int i = 0; i < 8; ++i) { 1355 for (int i = 0; i < 8; ++i) {
1357 SCOPED_TRACE(::testing::Message() << "Iteration " << i << 1356 SCOPED_TRACE(::testing::Message() << "Iteration " << i <<
1358 " incognito mode=" << test_profile->IsOffTheRecord()); 1357 " incognito mode=" << test_profile->IsOffTheRecord());
1359 SimulateNavigation(GURL("http://www.google.fr"), "fr", true); 1358 SimulateNavigation(GURL("http://www.google.fr"), "fr", true);
1360 infobar = GetTranslateInfoBar(); 1359 infobar = GetTranslateInfoBar();
1361 ASSERT_TRUE(infobar != NULL); 1360 ASSERT_TRUE(infobar != NULL);
1362 EXPECT_EQ(TranslateInfoBarDelegate::BEFORE_TRANSLATE, infobar->type()); 1361 EXPECT_EQ(TranslateInfoBarDelegate::BEFORE_TRANSLATE, infobar->type());
1363 if (i < 7) { 1362 if (i < 7) {
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
1460 NULL); 1459 NULL);
1461 // Now simulate the URL fetch. 1460 // Now simulate the URL fetch.
1462 SimulateTranslateScriptURLFetch(true); 1461 SimulateTranslateScriptURLFetch(true);
1463 // Now the message should have been sent. 1462 // Now the message should have been sent.
1464 int page_id = 0; 1463 int page_id = 0;
1465 std::string original_lang, target_lang; 1464 std::string original_lang, target_lang;
1466 EXPECT_TRUE(GetTranslateMessage(&page_id, &original_lang, &target_lang)); 1465 EXPECT_TRUE(GetTranslateMessage(&page_id, &original_lang, &target_lang));
1467 EXPECT_EQ("es", original_lang); 1466 EXPECT_EQ("es", original_lang);
1468 EXPECT_EQ("en", target_lang); 1467 EXPECT_EQ("en", target_lang);
1469 } 1468 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698