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

Side by Side Diff: chrome/browser/spellchecker/spellcheck_service_unittest.cc

Issue 17127002: Correctly integrate StoragePartition into TestingProfile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix InstantNTP test. Created 7 years, 5 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 #include <vector> 5 #include <vector>
6 6
7 #include "base/files/scoped_temp_dir.h" 7 #include "base/files/scoped_temp_dir.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "chrome/browser/spellchecker/spellcheck_custom_dictionary.h" 9 #include "chrome/browser/spellchecker/spellcheck_custom_dictionary.h"
10 #include "chrome/browser/spellchecker/spellcheck_factory.h" 10 #include "chrome/browser/spellchecker/spellcheck_factory.h"
11 #include "chrome/browser/spellchecker/spellcheck_service.h" 11 #include "chrome/browser/spellchecker/spellcheck_service.h"
12 #include "chrome/common/spellcheck_common.h" 12 #include "chrome/common/spellcheck_common.h"
13 #include "chrome/test/base/testing_profile.h" 13 #include "chrome/test/base/testing_profile.h"
14 #include "content/public/test/test_browser_thread.h" 14 #include "content/public/test/test_browser_thread_bundle.h"
15 #include "testing/gmock/include/gmock/gmock.h" 15 #include "testing/gmock/include/gmock/gmock.h"
16 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
17 17
18 using content::BrowserThread;
19 using chrome::spellcheck_common::WordList; 18 using chrome::spellcheck_common::WordList;
20 19
21 static BrowserContextKeyedService* BuildSpellcheckService( 20 static BrowserContextKeyedService* BuildSpellcheckService(
22 content::BrowserContext* profile) { 21 content::BrowserContext* profile) {
23 return new SpellcheckService(static_cast<Profile*>(profile)); 22 return new SpellcheckService(static_cast<Profile*>(profile));
24 } 23 }
25 24
26 class SpellcheckServiceTest : public testing::Test { 25 class SpellcheckServiceTest : public testing::Test {
27 protected: 26 protected:
28 SpellcheckServiceTest()
29 : ui_thread_(BrowserThread::UI, &message_loop_),
30 file_thread_(BrowserThread::FILE, &message_loop_),
31 profile_(new TestingProfile()) {
32 }
33
34 virtual void SetUp() OVERRIDE { 27 virtual void SetUp() OVERRIDE {
35 // Use SetTestingFactoryAndUse to force creation and initialization. 28 // Use SetTestingFactoryAndUse to force creation and initialization.
36 SpellcheckServiceFactory::GetInstance()->SetTestingFactoryAndUse( 29 SpellcheckServiceFactory::GetInstance()->SetTestingFactoryAndUse(
37 profile_.get(), &BuildSpellcheckService); 30 &profile_, &BuildSpellcheckService);
38 } 31 }
39 32
40 virtual void TearDown() OVERRIDE { 33 private:
41 base::MessageLoop::current()->RunUntilIdle(); 34 content::TestBrowserThreadBundle thread_bundle_;
42 } 35 TestingProfile profile_;
43
44 base::MessageLoop message_loop_;
45 content::TestBrowserThread ui_thread_;
46 content::TestBrowserThread file_thread_;
47
48 scoped_ptr<TestingProfile> profile_;
49 }; 36 };
50 37
51 TEST_F(SpellcheckServiceTest, GetSpellCheckLanguages1) { 38 TEST_F(SpellcheckServiceTest, GetSpellCheckLanguages1) {
52 std::vector<std::string> accept_languages; 39 std::vector<std::string> accept_languages;
53 accept_languages.push_back("en"); 40 accept_languages.push_back("en");
54 accept_languages.push_back("en-US"); 41 accept_languages.push_back("en-US");
55 std::vector<std::string> languages; 42 std::vector<std::string> languages;
56 43
57 SpellcheckService::GetSpellCheckLanguagesFromAcceptLanguages( 44 SpellcheckService::GetSpellCheckLanguagesFromAcceptLanguages(
58 accept_languages, "en-US", &languages); 45 accept_languages, "en-US", &languages);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 accept_languages.push_back("fr"); 102 accept_languages.push_back("fr");
116 accept_languages.push_back("aa"); // Will not exist. 103 accept_languages.push_back("aa"); // Will not exist.
117 std::vector<std::string> languages; 104 std::vector<std::string> languages;
118 105
119 SpellcheckService::GetSpellCheckLanguagesFromAcceptLanguages( 106 SpellcheckService::GetSpellCheckLanguagesFromAcceptLanguages(
120 accept_languages, "fr", &languages); 107 accept_languages, "fr", &languages);
121 108
122 EXPECT_EQ(1U, languages.size()); 109 EXPECT_EQ(1U, languages.size());
123 EXPECT_EQ("fr", languages[0]); 110 EXPECT_EQ("fr", languages[0]);
124 } 111 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698