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