| OLD | NEW |
| 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/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/metrics/histogram_samples.h" | 10 #include "base/metrics/histogram_samples.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 | 67 |
| 68 virtual void SetUp() OVERRIDE { | 68 virtual void SetUp() OVERRIDE { |
| 69 // Use SetTestingFactoryAndUse to force creation and initialization. | 69 // Use SetTestingFactoryAndUse to force creation and initialization. |
| 70 SpellcheckServiceFactory::GetInstance()->SetTestingFactoryAndUse( | 70 SpellcheckServiceFactory::GetInstance()->SetTestingFactoryAndUse( |
| 71 profile_.get(), &BuildSpellcheckService); | 71 profile_.get(), &BuildSpellcheckService); |
| 72 | 72 |
| 73 StatisticsRecorder::Initialize(); | 73 StatisticsRecorder::Initialize(); |
| 74 } | 74 } |
| 75 | 75 |
| 76 virtual void TearDown() OVERRIDE { | 76 virtual void TearDown() OVERRIDE { |
| 77 MessageLoop::current()->RunUntilIdle(); | 77 base::MessageLoop::current()->RunUntilIdle(); |
| 78 } | 78 } |
| 79 | 79 |
| 80 // A wrapper around SpellcheckCustomDictionary::LoadDictionaryFile private | 80 // A wrapper around SpellcheckCustomDictionary::LoadDictionaryFile private |
| 81 // function to avoid a large number of FRIEND_TEST declarations in | 81 // function to avoid a large number of FRIEND_TEST declarations in |
| 82 // SpellcheckCustomDictionary. | 82 // SpellcheckCustomDictionary. |
| 83 chrome::spellcheck_common::WordList LoadDictionaryFile( | 83 chrome::spellcheck_common::WordList LoadDictionaryFile( |
| 84 const base::FilePath& path) { | 84 const base::FilePath& path) { |
| 85 return SpellcheckCustomDictionary::LoadDictionaryFile(path); | 85 return SpellcheckCustomDictionary::LoadDictionaryFile(path); |
| 86 } | 86 } |
| 87 | 87 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 104 } | 104 } |
| 105 | 105 |
| 106 // A wrapper around SpellcheckCustomDictionary::Apply private method to avoid | 106 // A wrapper around SpellcheckCustomDictionary::Apply private method to avoid |
| 107 // a large number of FRIEND_TEST declarations in SpellcheckCustomDictionary. | 107 // a large number of FRIEND_TEST declarations in SpellcheckCustomDictionary. |
| 108 void Apply( | 108 void Apply( |
| 109 SpellcheckCustomDictionary& dictionary, | 109 SpellcheckCustomDictionary& dictionary, |
| 110 const SpellcheckCustomDictionary::Change& change) { | 110 const SpellcheckCustomDictionary::Change& change) { |
| 111 return dictionary.Apply(change); | 111 return dictionary.Apply(change); |
| 112 } | 112 } |
| 113 | 113 |
| 114 MessageLoop message_loop_; | 114 base::MessageLoop message_loop_; |
| 115 content::TestBrowserThread ui_thread_; | 115 content::TestBrowserThread ui_thread_; |
| 116 content::TestBrowserThread file_thread_; | 116 content::TestBrowserThread file_thread_; |
| 117 | 117 |
| 118 scoped_ptr<TestingProfile> profile_; | 118 scoped_ptr<TestingProfile> profile_; |
| 119 }; | 119 }; |
| 120 | 120 |
| 121 // A wrapper around SpellcheckCustomDictionary that does not own the wrapped | 121 // A wrapper around SpellcheckCustomDictionary that does not own the wrapped |
| 122 // object. An instance of this class can be inside of a scoped pointer safely | 122 // object. An instance of this class can be inside of a scoped pointer safely |
| 123 // while the dictionary is managed by another scoped pointer. | 123 // while the dictionary is managed by another scoped pointer. |
| 124 class SyncChangeProcessorDelegate : public syncer::SyncChangeProcessor { | 124 class SyncChangeProcessorDelegate : public syncer::SyncChangeProcessor { |
| (...skipping 993 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1118 EXPECT_EQ(2u, loaded_custom_words.size()); | 1118 EXPECT_EQ(2u, loaded_custom_words.size()); |
| 1119 | 1119 |
| 1120 histogram = | 1120 histogram = |
| 1121 StatisticsRecorder::FindHistogram("SpellCheck.CustomWords"); | 1121 StatisticsRecorder::FindHistogram("SpellCheck.CustomWords"); |
| 1122 ASSERT_TRUE(histogram != NULL); | 1122 ASSERT_TRUE(histogram != NULL); |
| 1123 scoped_ptr<HistogramSamples> samples2 = histogram->SnapshotSamples(); | 1123 scoped_ptr<HistogramSamples> samples2 = histogram->SnapshotSamples(); |
| 1124 | 1124 |
| 1125 samples2->Subtract(*baseline); | 1125 samples2->Subtract(*baseline); |
| 1126 EXPECT_EQ(2,samples2->sum()); | 1126 EXPECT_EQ(2,samples2->sum()); |
| 1127 } | 1127 } |
| OLD | NEW |