| 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 #include <vector> | 5 #include <vector> |
| 6 | 6 |
| 7 #include "base/scoped_temp_dir.h" | 7 #include "base/scoped_temp_dir.h" |
| 8 #include "chrome/browser/spellchecker/spellcheck_host.h" | 8 #include "chrome/browser/spellchecker/spellcheck_host.h" |
| 9 #include "chrome/browser/spellchecker/spellcheck_profile.h" | 9 #include "chrome/browser/spellchecker/spellcheck_profile.h" |
| 10 #include "content/test/test_browser_thread.h" | 10 #include "content/test/test_browser_thread.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 MOCK_CONST_METHOD0(GetMetrics, SpellCheckHostMetrics*()); | 27 MOCK_CONST_METHOD0(GetMetrics, SpellCheckHostMetrics*()); |
| 28 MOCK_CONST_METHOD0(IsReady, bool()); | 28 MOCK_CONST_METHOD0(IsReady, bool()); |
| 29 }; | 29 }; |
| 30 | 30 |
| 31 class TestingSpellCheckProfile : public SpellCheckProfile { | 31 class TestingSpellCheckProfile : public SpellCheckProfile { |
| 32 public: | 32 public: |
| 33 explicit TestingSpellCheckProfile(const FilePath& profile_dir) | 33 explicit TestingSpellCheckProfile(const FilePath& profile_dir) |
| 34 : SpellCheckProfile(profile_dir), | 34 : SpellCheckProfile(profile_dir), |
| 35 create_host_calls_(0) { | 35 create_host_calls_(0) { |
| 36 } | 36 } |
| 37 | |
| 38 virtual SpellCheckHost* CreateHost( | 37 virtual SpellCheckHost* CreateHost( |
| 39 SpellCheckProfileProvider* profile, | 38 SpellCheckProfileProvider* profile, |
| 40 const std::string& language, | 39 const std::string& language, |
| 41 net::URLRequestContextGetter* request_context, | 40 net::URLRequestContextGetter* request_context, |
| 42 SpellCheckHostMetrics* metrics) { | 41 SpellCheckHostMetrics* metrics) { |
| 43 create_host_calls_++; | 42 create_host_calls_++; |
| 44 return returning_from_create_.get(); | 43 return returning_from_create_.release(); |
| 45 } | 44 } |
| 46 | 45 |
| 47 virtual bool IsTesting() const { | 46 virtual bool IsTesting() const { |
| 48 return true; | 47 return true; |
| 49 } | 48 } |
| 50 | 49 |
| 51 bool IsCreatedHostReady() { | 50 bool IsCreatedHostReady() { |
| 52 return GetHost() == returning_from_create_.get(); | 51 return !!GetHost(); |
| 53 } | 52 } |
| 54 | 53 |
| 55 void SetHostToBeCreated(MockSpellCheckHost* host) { | 54 void SetHostToBeCreated(MockSpellCheckHost* host) { |
| 56 EXPECT_CALL(*host, UnsetProfile()).Times(1); | 55 EXPECT_CALL(*host, UnsetProfile()).Times(1); |
| 57 EXPECT_CALL(*host, IsReady()).WillRepeatedly(testing::Return(true)); | 56 EXPECT_CALL(*host, IsReady()).WillRepeatedly(testing::Return(true)); |
| 58 returning_from_create_ = host; | 57 returning_from_create_.reset(host); |
| 59 } | 58 } |
| 60 | 59 |
| 61 size_t create_host_calls_; | 60 size_t create_host_calls_; |
| 62 scoped_refptr<SpellCheckHost> returning_from_create_; | 61 scoped_ptr<SpellCheckHost> returning_from_create_; |
| 63 }; | 62 }; |
| 64 | 63 |
| 65 typedef SpellCheckProfile::ReinitializeResult ResultType; | 64 typedef SpellCheckProfile::ReinitializeResult ResultType; |
| 66 } // namespace | 65 } // namespace |
| 67 | 66 |
| 68 class SpellCheckProfileTest : public testing::Test { | 67 class SpellCheckProfileTest : public testing::Test { |
| 69 protected: | 68 protected: |
| 70 SpellCheckProfileTest() | 69 SpellCheckProfileTest() |
| 71 : file_thread_(BrowserThread::FILE) { | 70 : file_thread_(BrowserThread::FILE) { |
| 72 } | 71 } |
| 73 | 72 |
| 74 // SpellCheckHost will be deleted on FILE thread. | 73 // SpellCheckHost will be deleted on FILE thread. |
| 75 content::TestBrowserThread file_thread_; | 74 content::TestBrowserThread file_thread_; |
| 76 }; | 75 }; |
| 77 | 76 |
| 78 TEST_F(SpellCheckProfileTest, ReinitializeEnabled) { | 77 TEST_F(SpellCheckProfileTest, ReinitializeEnabled) { |
| 79 scoped_refptr<MockSpellCheckHost> host(new MockSpellCheckHost()); | 78 scoped_ptr<MockSpellCheckHost> host(new MockSpellCheckHost()); |
| 80 ScopedTempDir dir; | 79 ScopedTempDir dir; |
| 81 ASSERT_TRUE(dir.CreateUniqueTempDir()); | 80 ASSERT_TRUE(dir.CreateUniqueTempDir()); |
| 82 TestingSpellCheckProfile target(dir.path()); | 81 TestingSpellCheckProfile target(dir.path()); |
| 83 target.SetHostToBeCreated(host.get()); | 82 target.SetHostToBeCreated(host.release()); |
| 84 | 83 |
| 85 // The first call should create host. | 84 // The first call should create host. |
| 86 ResultType result1 = target.ReinitializeHost(false, true, "", NULL); | 85 ResultType result1 = target.ReinitializeHost(false, true, "", NULL); |
| 87 EXPECT_EQ(target.create_host_calls_, 1U); | 86 EXPECT_EQ(target.create_host_calls_, 1U); |
| 88 EXPECT_EQ(result1, SpellCheckProfile::REINITIALIZE_CREATED_HOST); | 87 EXPECT_EQ(result1, SpellCheckProfile::REINITIALIZE_CREATED_HOST); |
| 89 | 88 |
| 90 // The second call should be ignored. | 89 // The second call should be ignored. |
| 91 ResultType result2 = target.ReinitializeHost(false, true, "", NULL); | 90 ResultType result2 = target.ReinitializeHost(false, true, "", NULL); |
| 92 EXPECT_EQ(result2, SpellCheckProfile::REINITIALIZE_DID_NOTHING); | 91 EXPECT_EQ(result2, SpellCheckProfile::REINITIALIZE_DID_NOTHING); |
| 93 EXPECT_EQ(target.create_host_calls_, 1U); | 92 EXPECT_EQ(target.create_host_calls_, 1U); |
| 94 | 93 |
| 95 // Host should become ready after the notification. | 94 // Host should become ready after the notification. |
| 96 EXPECT_FALSE(target.IsCreatedHostReady()); | 95 EXPECT_FALSE(target.IsCreatedHostReady()); |
| 97 target.SpellCheckHostInitialized(0); | 96 target.SpellCheckHostInitialized(0); |
| 98 EXPECT_TRUE(target.IsCreatedHostReady()); | 97 EXPECT_TRUE(target.IsCreatedHostReady()); |
| 99 } | 98 } |
| 100 | 99 |
| 101 TEST_F(SpellCheckProfileTest, ReinitializeDisabled) { | 100 TEST_F(SpellCheckProfileTest, ReinitializeDisabled) { |
| 102 scoped_refptr<MockSpellCheckHost> host(new MockSpellCheckHost()); | 101 scoped_ptr<MockSpellCheckHost> host(new MockSpellCheckHost()); |
| 103 ScopedTempDir dir; | 102 ScopedTempDir dir; |
| 104 ASSERT_TRUE(dir.CreateUniqueTempDir()); | 103 ASSERT_TRUE(dir.CreateUniqueTempDir()); |
| 105 TestingSpellCheckProfile target(dir.path()); | 104 TestingSpellCheckProfile target(dir.path()); |
| 106 | 105 |
| 107 target.returning_from_create_ = host.get(); | 106 target.returning_from_create_.reset(host.release()); |
| 108 | 107 |
| 109 // If enabled is false, nothing should happen | 108 // If enabled is false, nothing should happen |
| 110 ResultType result1 = target.ReinitializeHost(false, false, "", NULL); | 109 ResultType result1 = target.ReinitializeHost(false, false, "", NULL); |
| 111 EXPECT_EQ(target.create_host_calls_, 0U); | 110 EXPECT_EQ(target.create_host_calls_, 0U); |
| 112 EXPECT_EQ(result1, SpellCheckProfile::REINITIALIZE_DID_NOTHING); | 111 EXPECT_EQ(result1, SpellCheckProfile::REINITIALIZE_DID_NOTHING); |
| 113 | 112 |
| 114 // Nothing should happen even if forced. | 113 // Nothing should happen even if forced. |
| 115 ResultType result2 = target.ReinitializeHost(true, false, "", NULL); | 114 ResultType result2 = target.ReinitializeHost(true, false, "", NULL); |
| 116 EXPECT_EQ(target.create_host_calls_, 0U); | 115 EXPECT_EQ(target.create_host_calls_, 0U); |
| 117 EXPECT_EQ(result2, SpellCheckProfile::REINITIALIZE_DID_NOTHING); | 116 EXPECT_EQ(result2, SpellCheckProfile::REINITIALIZE_DID_NOTHING); |
| 118 } | 117 } |
| 119 | 118 |
| 120 TEST_F(SpellCheckProfileTest, ReinitializeRemove) { | 119 TEST_F(SpellCheckProfileTest, ReinitializeRemove) { |
| 121 scoped_refptr<MockSpellCheckHost> host(new MockSpellCheckHost()); | 120 scoped_ptr<MockSpellCheckHost> host(new MockSpellCheckHost()); |
| 122 ScopedTempDir dir; | 121 ScopedTempDir dir; |
| 123 ASSERT_TRUE(dir.CreateUniqueTempDir()); | 122 ASSERT_TRUE(dir.CreateUniqueTempDir()); |
| 124 TestingSpellCheckProfile target(dir.path()); | 123 TestingSpellCheckProfile target(dir.path()); |
| 125 | 124 |
| 126 target.SetHostToBeCreated(host.get()); | 125 target.SetHostToBeCreated(host.release()); |
| 127 | 126 |
| 128 // At first, create the host. | 127 // At first, create the host. |
| 129 ResultType result1 = target.ReinitializeHost(false, true, "", NULL); | 128 ResultType result1 = target.ReinitializeHost(false, true, "", NULL); |
| 130 target.SpellCheckHostInitialized(0); | 129 target.SpellCheckHostInitialized(0); |
| 131 EXPECT_EQ(result1, SpellCheckProfile::REINITIALIZE_CREATED_HOST); | 130 EXPECT_EQ(result1, SpellCheckProfile::REINITIALIZE_CREATED_HOST); |
| 132 EXPECT_TRUE(target.IsCreatedHostReady()); | 131 EXPECT_TRUE(target.IsCreatedHostReady()); |
| 133 | 132 |
| 134 // Then the host should be deleted if it's forced to be disabled. | 133 // Then the host should be deleted if it's forced to be disabled. |
| 135 ResultType result2 = target.ReinitializeHost(true, false, "", NULL); | 134 ResultType result2 = target.ReinitializeHost(true, false, "", NULL); |
| 136 target.SpellCheckHostInitialized(0); | 135 target.SpellCheckHostInitialized(0); |
| 137 EXPECT_EQ(result2, SpellCheckProfile::REINITIALIZE_REMOVED_HOST); | 136 EXPECT_EQ(result2, SpellCheckProfile::REINITIALIZE_REMOVED_HOST); |
| 138 EXPECT_FALSE(target.IsCreatedHostReady()); | 137 EXPECT_FALSE(target.IsCreatedHostReady()); |
| 139 } | 138 } |
| 140 | 139 |
| 141 TEST_F(SpellCheckProfileTest, ReinitializeRecreate) { | 140 TEST_F(SpellCheckProfileTest, ReinitializeRecreate) { |
| 142 scoped_refptr<MockSpellCheckHost> host1(new MockSpellCheckHost()); | 141 scoped_ptr<MockSpellCheckHost> host1(new MockSpellCheckHost()); |
| 143 ScopedTempDir dir; | 142 ScopedTempDir dir; |
| 144 ASSERT_TRUE(dir.CreateUniqueTempDir()); | 143 ASSERT_TRUE(dir.CreateUniqueTempDir()); |
| 145 TestingSpellCheckProfile target(dir.path()); | 144 TestingSpellCheckProfile target(dir.path()); |
| 146 | 145 |
| 147 target.SetHostToBeCreated(host1.get()); | 146 target.SetHostToBeCreated(host1.release()); |
| 148 | 147 |
| 149 // At first, create the host. | 148 // At first, create the host. |
| 150 ResultType result1 = target.ReinitializeHost(false, true, "", NULL); | 149 ResultType result1 = target.ReinitializeHost(false, true, "", NULL); |
| 151 target.SpellCheckHostInitialized(0); | 150 target.SpellCheckHostInitialized(0); |
| 152 EXPECT_EQ(target.create_host_calls_, 1U); | 151 EXPECT_EQ(target.create_host_calls_, 1U); |
| 153 EXPECT_EQ(result1, SpellCheckProfile::REINITIALIZE_CREATED_HOST); | 152 EXPECT_EQ(result1, SpellCheckProfile::REINITIALIZE_CREATED_HOST); |
| 154 EXPECT_TRUE(target.IsCreatedHostReady()); | 153 EXPECT_TRUE(target.IsCreatedHostReady()); |
| 155 | 154 |
| 156 // Then the host should be re-created if it's forced to recreate. | 155 // Then the host should be re-created if it's forced to recreate. |
| 157 scoped_refptr<MockSpellCheckHost> host2(new MockSpellCheckHost()); | 156 scoped_ptr<MockSpellCheckHost> host2(new MockSpellCheckHost()); |
| 158 target.SetHostToBeCreated(host2.get()); | 157 target.SetHostToBeCreated(host2.release()); |
| 159 | 158 |
| 160 ResultType result2 = target.ReinitializeHost(true, true, "", NULL); | 159 ResultType result2 = target.ReinitializeHost(true, true, "", NULL); |
| 161 target.SpellCheckHostInitialized(0); | 160 target.SpellCheckHostInitialized(0); |
| 162 EXPECT_EQ(target.create_host_calls_, 2U); | 161 EXPECT_EQ(target.create_host_calls_, 2U); |
| 163 EXPECT_EQ(result2, SpellCheckProfile::REINITIALIZE_CREATED_HOST); | 162 EXPECT_EQ(result2, SpellCheckProfile::REINITIALIZE_CREATED_HOST); |
| 164 EXPECT_TRUE(target.IsCreatedHostReady()); | 163 EXPECT_TRUE(target.IsCreatedHostReady()); |
| 165 } | 164 } |
| 166 | 165 |
| 167 TEST_F(SpellCheckProfileTest, SpellCheckHostInitializedWithCustomWords) { | 166 TEST_F(SpellCheckProfileTest, SpellCheckHostInitializedWithCustomWords) { |
| 168 scoped_refptr<MockSpellCheckHost> host(new MockSpellCheckHost()); | 167 scoped_ptr<MockSpellCheckHost> host(new MockSpellCheckHost()); |
| 169 ScopedTempDir dir; | 168 ScopedTempDir dir; |
| 170 ASSERT_TRUE(dir.CreateUniqueTempDir()); | 169 ASSERT_TRUE(dir.CreateUniqueTempDir()); |
| 171 TestingSpellCheckProfile target(dir.path()); | 170 TestingSpellCheckProfile target(dir.path()); |
| 172 | 171 |
| 173 target.SetHostToBeCreated(host.get()); | 172 target.SetHostToBeCreated(host.release()); |
| 174 target.ReinitializeHost(false, true, "", NULL); | 173 target.ReinitializeHost(false, true, "", NULL); |
| 175 | 174 |
| 176 scoped_ptr<SpellCheckProfile::CustomWordList> loaded_custom_words | 175 scoped_ptr<SpellCheckProfile::CustomWordList> loaded_custom_words |
| 177 (new SpellCheckProfile::CustomWordList()); | 176 (new SpellCheckProfile::CustomWordList()); |
| 178 loaded_custom_words->push_back("foo"); | 177 loaded_custom_words->push_back("foo"); |
| 179 loaded_custom_words->push_back("bar"); | 178 loaded_custom_words->push_back("bar"); |
| 180 SpellCheckProfile::CustomWordList expected(*loaded_custom_words); | 179 SpellCheckProfile::CustomWordList expected(*loaded_custom_words); |
| 181 target.SpellCheckHostInitialized(loaded_custom_words.release()); | 180 target.SpellCheckHostInitialized(loaded_custom_words.release()); |
| 182 EXPECT_EQ(target.GetCustomWords(), expected); | 181 EXPECT_EQ(target.GetCustomWords(), expected); |
| 183 } | 182 } |
| 184 | 183 |
| 185 TEST_F(SpellCheckProfileTest, CustomWordAddedLocally) { | 184 TEST_F(SpellCheckProfileTest, CustomWordAddedLocally) { |
| 186 scoped_refptr<MockSpellCheckHost> host(new MockSpellCheckHost()); | 185 scoped_ptr<MockSpellCheckHost> host(new MockSpellCheckHost()); |
| 187 ScopedTempDir dir; | 186 ScopedTempDir dir; |
| 188 ASSERT_TRUE(dir.CreateUniqueTempDir()); | 187 ASSERT_TRUE(dir.CreateUniqueTempDir()); |
| 189 TestingSpellCheckProfile target(dir.path()); | 188 TestingSpellCheckProfile target(dir.path()); |
| 190 | 189 |
| 191 target.SetHostToBeCreated(host.get()); | 190 target.SetHostToBeCreated(host.release()); |
| 192 target.ReinitializeHost(false, true, "", NULL); | 191 target.ReinitializeHost(false, true, "", NULL); |
| 193 | 192 |
| 194 scoped_ptr<SpellCheckProfile::CustomWordList> loaded_custom_words | 193 scoped_ptr<SpellCheckProfile::CustomWordList> loaded_custom_words |
| 195 (new SpellCheckProfile::CustomWordList()); | 194 (new SpellCheckProfile::CustomWordList()); |
| 196 target.SpellCheckHostInitialized(NULL); | 195 target.SpellCheckHostInitialized(NULL); |
| 197 SpellCheckProfile::CustomWordList expected; | 196 SpellCheckProfile::CustomWordList expected; |
| 198 EXPECT_EQ(target.GetCustomWords(), expected); | 197 EXPECT_EQ(target.GetCustomWords(), expected); |
| 199 target.CustomWordAddedLocally("foo"); | 198 target.CustomWordAddedLocally("foo"); |
| 200 expected.push_back("foo"); | 199 expected.push_back("foo"); |
| 201 EXPECT_EQ(target.GetCustomWords(), expected); | 200 EXPECT_EQ(target.GetCustomWords(), expected); |
| 202 target.CustomWordAddedLocally("bar"); | 201 target.CustomWordAddedLocally("bar"); |
| 203 expected.push_back("bar"); | 202 expected.push_back("bar"); |
| 204 EXPECT_EQ(target.GetCustomWords(), expected); | 203 EXPECT_EQ(target.GetCustomWords(), expected); |
| 205 } | 204 } |
| 206 | 205 |
| 207 TEST_F(SpellCheckProfileTest, SaveAndLoad) { | 206 TEST_F(SpellCheckProfileTest, SaveAndLoad) { |
| 208 scoped_refptr<MockSpellCheckHost> host(new MockSpellCheckHost()); | 207 scoped_ptr<MockSpellCheckHost> host(new MockSpellCheckHost()); |
| 209 ScopedTempDir dir; | 208 ScopedTempDir dir; |
| 210 ASSERT_TRUE(dir.CreateUniqueTempDir()); | 209 ASSERT_TRUE(dir.CreateUniqueTempDir()); |
| 211 TestingSpellCheckProfile target(dir.path()); | 210 TestingSpellCheckProfile target(dir.path()); |
| 212 | 211 |
| 213 target.SetHostToBeCreated(host.get()); | 212 target.SetHostToBeCreated(host.release()); |
| 214 target.ReinitializeHost(false, true, "", NULL); | 213 target.ReinitializeHost(false, true, "", NULL); |
| 215 | 214 |
| 216 scoped_ptr<SpellCheckProfile::CustomWordList> loaded_custom_words( | 215 scoped_ptr<SpellCheckProfile::CustomWordList> loaded_custom_words( |
| 217 new SpellCheckProfile::CustomWordList()); | 216 new SpellCheckProfile::CustomWordList()); |
| 218 target.LoadCustomDictionary(loaded_custom_words.get()); | 217 target.LoadCustomDictionary(loaded_custom_words.get()); |
| 219 | 218 |
| 220 // The custom word list should be empty now. | 219 // The custom word list should be empty now. |
| 221 SpellCheckProfile::CustomWordList expected; | 220 SpellCheckProfile::CustomWordList expected; |
| 222 EXPECT_EQ(*loaded_custom_words, expected); | 221 EXPECT_EQ(*loaded_custom_words, expected); |
| 223 | 222 |
| 224 target.WriteWordToCustomDictionary("foo"); | 223 target.WriteWordToCustomDictionary("foo"); |
| 225 expected.push_back("foo"); | 224 expected.push_back("foo"); |
| 226 | 225 |
| 227 target.WriteWordToCustomDictionary("bar"); | 226 target.WriteWordToCustomDictionary("bar"); |
| 228 expected.push_back("bar"); | 227 expected.push_back("bar"); |
| 229 | 228 |
| 230 // The custom word list should include written words. | 229 // The custom word list should include written words. |
| 231 target.LoadCustomDictionary(loaded_custom_words.get()); | 230 target.LoadCustomDictionary(loaded_custom_words.get()); |
| 232 EXPECT_EQ(*loaded_custom_words, expected); | 231 EXPECT_EQ(*loaded_custom_words, expected); |
| 233 | 232 |
| 234 // Load in another instance of SpellCheckProfile. | 233 // Load in another instance of SpellCheckProfile. |
| 235 // The result should be the same. | 234 // The result should be the same. |
| 236 scoped_refptr<MockSpellCheckHost> host2(new MockSpellCheckHost()); | 235 scoped_ptr<MockSpellCheckHost> host2(new MockSpellCheckHost()); |
| 237 TestingSpellCheckProfile target2(dir.path()); | 236 TestingSpellCheckProfile target2(dir.path()); |
| 238 target2.SetHostToBeCreated(host2.get()); | 237 target2.SetHostToBeCreated(host2.release()); |
| 239 target2.ReinitializeHost(false, true, "", NULL); | 238 target2.ReinitializeHost(false, true, "", NULL); |
| 240 scoped_ptr<SpellCheckProfile::CustomWordList> loaded_custom_words2( | 239 scoped_ptr<SpellCheckProfile::CustomWordList> loaded_custom_words2( |
| 241 new SpellCheckProfile::CustomWordList()); | 240 new SpellCheckProfile::CustomWordList()); |
| 242 target2.LoadCustomDictionary(loaded_custom_words2.get()); | 241 target2.LoadCustomDictionary(loaded_custom_words2.get()); |
| 243 EXPECT_EQ(*loaded_custom_words2, expected); | 242 EXPECT_EQ(*loaded_custom_words2, expected); |
| 244 } | 243 } |
| 245 | 244 |
| 246 TEST_F(SpellCheckProfileTest, MultiProfile) { | 245 TEST_F(SpellCheckProfileTest, MultiProfile) { |
| 247 scoped_refptr<MockSpellCheckHost> host1(new MockSpellCheckHost()); | 246 scoped_ptr<MockSpellCheckHost> host1(new MockSpellCheckHost()); |
| 248 scoped_refptr<MockSpellCheckHost> host2(new MockSpellCheckHost()); | 247 scoped_ptr<MockSpellCheckHost> host2(new MockSpellCheckHost()); |
| 249 | 248 |
| 250 ScopedTempDir dir1; | 249 ScopedTempDir dir1; |
| 251 ScopedTempDir dir2; | 250 ScopedTempDir dir2; |
| 252 ASSERT_TRUE(dir1.CreateUniqueTempDir()); | 251 ASSERT_TRUE(dir1.CreateUniqueTempDir()); |
| 253 ASSERT_TRUE(dir2.CreateUniqueTempDir()); | 252 ASSERT_TRUE(dir2.CreateUniqueTempDir()); |
| 254 TestingSpellCheckProfile target1(dir1.path()); | 253 TestingSpellCheckProfile target1(dir1.path()); |
| 255 TestingSpellCheckProfile target2(dir2.path()); | 254 TestingSpellCheckProfile target2(dir2.path()); |
| 256 | 255 |
| 257 target1.SetHostToBeCreated(host1.get()); | 256 target1.SetHostToBeCreated(host1.release()); |
| 258 target1.ReinitializeHost(false, true, "", NULL); | 257 target1.ReinitializeHost(false, true, "", NULL); |
| 259 target2.SetHostToBeCreated(host2.get()); | 258 target2.SetHostToBeCreated(host2.release()); |
| 260 target2.ReinitializeHost(false, true, "", NULL); | 259 target2.ReinitializeHost(false, true, "", NULL); |
| 261 | 260 |
| 262 SpellCheckProfile::CustomWordList expected1; | 261 SpellCheckProfile::CustomWordList expected1; |
| 263 SpellCheckProfile::CustomWordList expected2; | 262 SpellCheckProfile::CustomWordList expected2; |
| 264 | 263 |
| 265 target1.WriteWordToCustomDictionary("foo"); | 264 target1.WriteWordToCustomDictionary("foo"); |
| 266 target1.WriteWordToCustomDictionary("bar"); | 265 target1.WriteWordToCustomDictionary("bar"); |
| 267 expected1.push_back("foo"); | 266 expected1.push_back("foo"); |
| 268 expected1.push_back("bar"); | 267 expected1.push_back("bar"); |
| 269 | 268 |
| 270 target2.WriteWordToCustomDictionary("hoge"); | 269 target2.WriteWordToCustomDictionary("hoge"); |
| 271 target2.WriteWordToCustomDictionary("fuga"); | 270 target2.WriteWordToCustomDictionary("fuga"); |
| 272 expected2.push_back("hoge"); | 271 expected2.push_back("hoge"); |
| 273 expected2.push_back("fuga"); | 272 expected2.push_back("fuga"); |
| 274 | 273 |
| 275 SpellCheckProfile::CustomWordList actual1; | 274 SpellCheckProfile::CustomWordList actual1; |
| 276 target1.LoadCustomDictionary(&actual1); | 275 target1.LoadCustomDictionary(&actual1); |
| 277 EXPECT_EQ(actual1, expected1); | 276 EXPECT_EQ(actual1, expected1); |
| 278 | 277 |
| 279 SpellCheckProfile::CustomWordList actual2; | 278 SpellCheckProfile::CustomWordList actual2; |
| 280 target2.LoadCustomDictionary(&actual2); | 279 target2.LoadCustomDictionary(&actual2); |
| 281 EXPECT_EQ(actual2, expected2); | 280 EXPECT_EQ(actual2, expected2); |
| 282 } | 281 } |
| OLD | NEW |