Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(747)

Side by Side Diff: chrome/browser/spellchecker/spellcheck_host_browsertest.cc

Issue 10573017: Rename SpellCheckCommon namespace to chrome. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_host.h" 9 #include "chrome/browser/spellchecker/spellcheck_host.h"
10 #include "chrome/browser/ui/browser.h" 10 #include "chrome/browser/ui/browser.h"
(...skipping 24 matching lines...) Expand all
35 class SpellCheckHostBrowserTest : public InProcessBrowserTest { 35 class SpellCheckHostBrowserTest : public InProcessBrowserTest {
36 }; 36 };
37 37
38 // Tests that we can delete a corrupted BDICT file used by hunspell. We do not 38 // Tests that we can delete a corrupted BDICT file used by hunspell. We do not
39 // run this test on Mac because Mac does not use hunspell by default. 39 // run this test on Mac because Mac does not use hunspell by default.
40 IN_PROC_BROWSER_TEST_F(SpellCheckHostBrowserTest, DeleteCorruptedBDICT) { 40 IN_PROC_BROWSER_TEST_F(SpellCheckHostBrowserTest, DeleteCorruptedBDICT) {
41 // Write the corrupted BDICT data to create a corrupted BDICT file. 41 // Write the corrupted BDICT data to create a corrupted BDICT file.
42 FilePath dict_dir; 42 FilePath dict_dir;
43 ASSERT_TRUE(PathService::Get(chrome::DIR_APP_DICTIONARIES, &dict_dir)); 43 ASSERT_TRUE(PathService::Get(chrome::DIR_APP_DICTIONARIES, &dict_dir));
44 FilePath bdict_path = 44 FilePath bdict_path =
45 SpellCheckCommon::GetVersionedFileName("en-US", dict_dir); 45 chrome::spellcheck_common::GetVersionedFileName("en-US", dict_dir);
46 46
47 size_t actual = file_util::WriteFile(bdict_path, 47 size_t actual = file_util::WriteFile(bdict_path,
48 reinterpret_cast<const char*>(kCorruptedBDICT), 48 reinterpret_cast<const char*>(kCorruptedBDICT),
49 arraysize(kCorruptedBDICT)); 49 arraysize(kCorruptedBDICT));
50 EXPECT_EQ(arraysize(kCorruptedBDICT), actual); 50 EXPECT_EQ(arraysize(kCorruptedBDICT), actual);
51 51
52 // Attach an event to the SpellCheckHost object so we can receive its status 52 // Attach an event to the SpellCheckHost object so we can receive its status
53 // updates. 53 // updates.
54 base::WaitableEvent event(true, false); 54 base::WaitableEvent event(true, false);
55 SpellCheckHost::AttachStatusEvent(&event); 55 SpellCheckHost::AttachStatusEvent(&event);
56 56
57 // Initialize the SpellCheckHost object with the corrupted BDICT file created 57 // Initialize the SpellCheckHost object with the corrupted BDICT file created
58 // above. The SpellCheckHost object will send a BDICT_CORRUPTED event. 58 // above. The SpellCheckHost object will send a BDICT_CORRUPTED event.
59 SpellCheckFactory::ReinitializeSpellCheckHost(browser()->profile(), false); 59 SpellCheckFactory::ReinitializeSpellCheckHost(browser()->profile(), false);
60 60
61 // Check the received event. Also we check if Chrome has successfully deleted 61 // Check the received event. Also we check if Chrome has successfully deleted
62 // the corrupted dictionary. We delete the corrupted dictionary to avoid 62 // the corrupted dictionary. We delete the corrupted dictionary to avoid
63 // leaking it when this test fails. 63 // leaking it when this test fails.
64 int type = SpellCheckHost::WaitStatusEvent(); 64 int type = SpellCheckHost::WaitStatusEvent();
65 EXPECT_EQ(SpellCheckHost::BDICT_CORRUPTED, type); 65 EXPECT_EQ(SpellCheckHost::BDICT_CORRUPTED, type);
66 if (file_util::PathExists(bdict_path)) { 66 if (file_util::PathExists(bdict_path)) {
67 ADD_FAILURE(); 67 ADD_FAILURE();
68 EXPECT_TRUE(file_util::Delete(bdict_path, true)); 68 EXPECT_TRUE(file_util::Delete(bdict_path, true));
69 } 69 }
70 } 70 }
OLDNEW
« no previous file with comments | « chrome/browser/spellchecker/spellcheck_host.cc ('k') | chrome/browser/spellchecker/spellcheck_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698