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