Chromium Code Reviews| 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 "base/path_service.h" | 5 #include "base/path_service.h" |
| 6 #include "base/synchronization/waitable_event.h" | 6 #include "base/synchronization/waitable_event.h" |
| 7 #include "chrome/browser/profiles/profile.h" | 7 #include "chrome/browser/profiles/profile.h" |
| 8 #include "chrome/browser/spellchecker/spellcheck_factory.h" | 8 #include "chrome/browser/spellchecker/spellcheck_factory.h" |
| 9 #include "chrome/browser/spellchecker/spellcheck_service.h" | 9 #include "chrome/browser/spellchecker/spellcheck_service.h" |
| 10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 54 EXPECT_EQ(arraysize(kCorruptedBDICT), actual); | 54 EXPECT_EQ(arraysize(kCorruptedBDICT), actual); |
| 55 | 55 |
| 56 // Attach an event to the SpellcheckService object so we can receive its | 56 // Attach an event to the SpellcheckService object so we can receive its |
| 57 // status updates. | 57 // status updates. |
| 58 base::WaitableEvent event(true, false); | 58 base::WaitableEvent event(true, false); |
| 59 SpellcheckService::AttachStatusEvent(&event); | 59 SpellcheckService::AttachStatusEvent(&event); |
| 60 | 60 |
| 61 // Ensure that the SpellcheckService object does not already exist. Otherwise | 61 // Ensure that the SpellcheckService object does not already exist. Otherwise |
| 62 // the next line will not force creation of the SpellcheckService and the | 62 // the next line will not force creation of the SpellcheckService and the |
| 63 // test will fail. | 63 // test will fail. |
| 64 SpellcheckService* service = | 64 SpellcheckService* service = static_cast<SpellcheckService*>( |
| 65 SpellcheckServiceFactory::GetForProfileWithoutCreating(GetProfile()); | 65 GetInstance()->GetServiceForBrowserContext(context, false)); |
|
groby-ooo-7-16
2013/09/10 19:09:51
Does this get the context somewhere? Can't see tha
msmith.v3
2013/09/10 19:27:50
Yep - copy-paste error. Sure that's going to break
msmith.v3
2013/09/11 19:25:07
This turned out to be problematic. The reason for
groby-ooo-7-16
2013/09/12 21:35:53
Expose it in spellcheck_factory.h via FRIEND_TEST_
msmith.v3
2013/09/13 17:02:14
Done.
| |
| 66 ASSERT_EQ(NULL, service); | 66 ASSERT_EQ(NULL, service); |
| 67 | 67 |
| 68 // Getting the spellcheck_service will initialize the SpellcheckService | 68 // Getting the spellcheck_service will initialize the SpellcheckService |
| 69 // object with the corrupted BDICT file created above since the hunspell | 69 // object with the corrupted BDICT file created above since the hunspell |
| 70 // dictionary is loaded in the SpellcheckService constructor right now. | 70 // dictionary is loaded in the SpellcheckService constructor right now. |
| 71 // The SpellCheckHost object will send a BDICT_CORRUPTED event. | 71 // The SpellCheckHost object will send a BDICT_CORRUPTED event. |
| 72 SpellcheckServiceFactory::GetForProfile(GetProfile()); | 72 SpellcheckServiceFactory::GetForContext(GetProfile()); |
|
groby-ooo-7-16
2013/09/10 19:09:51
Use context.
msmith.v3
2013/09/10 19:27:50
What's the proper way to grab the context inside o
groby-ooo-7-16
2013/09/10 20:48:07
GetProfile() is fine - I was just assuming you'd a
msmith.v3
2013/09/13 17:02:14
Done.
| |
| 73 | 73 |
| 74 // Check the received event. Also we check if Chrome has successfully deleted | 74 // Check the received event. Also we check if Chrome has successfully deleted |
| 75 // the corrupted dictionary. We delete the corrupted dictionary to avoid | 75 // the corrupted dictionary. We delete the corrupted dictionary to avoid |
| 76 // leaking it when this test fails. | 76 // leaking it when this test fails. |
| 77 content::RunAllPendingInMessageLoop(content::BrowserThread::FILE); | 77 content::RunAllPendingInMessageLoop(content::BrowserThread::FILE); |
| 78 content::RunAllPendingInMessageLoop(content::BrowserThread::UI); | 78 content::RunAllPendingInMessageLoop(content::BrowserThread::UI); |
| 79 EXPECT_EQ(SpellcheckService::BDICT_CORRUPTED, | 79 EXPECT_EQ(SpellcheckService::BDICT_CORRUPTED, |
| 80 SpellcheckService::GetStatusEvent()); | 80 SpellcheckService::GetStatusEvent()); |
| 81 if (base::PathExists(bdict_path)) { | 81 if (base::PathExists(bdict_path)) { |
| 82 ADD_FAILURE(); | 82 ADD_FAILURE(); |
| 83 EXPECT_TRUE(base::DeleteFile(bdict_path, true)); | 83 EXPECT_TRUE(base::DeleteFile(bdict_path, true)); |
| 84 } | 84 } |
| 85 } | 85 } |
| OLD | NEW |