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

Side by Side Diff: chrome/browser/extensions/menu_manager_unittest.cc

Issue 11027070: Moved JsonPrefStore to use SequencedWorkerPool (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 2 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 <vector> 5 #include <vector>
6 6
7 #include "base/json/json_reader.h" 7 #include "base/json/json_reader.h"
8 #include "base/memory/scoped_vector.h" 8 #include "base/memory/scoped_vector.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
11 #include "base/scoped_temp_dir.h" 11 #include "base/scoped_temp_dir.h"
12 #include "base/utf_string_conversions.h" 12 #include "base/utf_string_conversions.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "chrome/browser/extensions/event_names.h" 14 #include "chrome/browser/extensions/event_names.h"
15 #include "chrome/browser/extensions/event_router.h" 15 #include "chrome/browser/extensions/event_router.h"
16 #include "chrome/browser/extensions/menu_manager.h" 16 #include "chrome/browser/extensions/menu_manager.h"
17 #include "chrome/browser/prefs/pref_service.h"
17 #include "chrome/browser/extensions/test_extension_prefs.h" 18 #include "chrome/browser/extensions/test_extension_prefs.h"
18 #include "chrome/common/chrome_notification_types.h" 19 #include "chrome/common/chrome_notification_types.h"
19 #include "chrome/common/chrome_paths.h" 20 #include "chrome/common/chrome_paths.h"
20 #include "chrome/common/extensions/extension.h" 21 #include "chrome/common/extensions/extension.h"
21 #include "chrome/common/extensions/extension_constants.h" 22 #include "chrome/common/extensions/extension_constants.h"
22 #include "chrome/test/base/testing_profile.h" 23 #include "chrome/test/base/testing_profile.h"
23 #include "content/public/browser/notification_service.h" 24 #include "content/public/browser/notification_service.h"
24 #include "content/public/common/context_menu_params.h" 25 #include "content/public/common/context_menu_params.h"
25 #include "content/public/test/test_browser_thread.h" 26 #include "content/public/test/test_browser_thread.h"
26 #include "testing/gmock/include/gmock/gmock.h" 27 #include "testing/gmock/include/gmock/gmock.h"
27 #include "testing/gtest/include/gtest/gtest.h" 28 #include "testing/gtest/include/gtest/gtest.h"
28 29
29 using content::BrowserThread; 30 using content::BrowserThread;
30 using testing::_; 31 using testing::_;
31 using testing::AtLeast; 32 using testing::AtLeast;
32 using testing::DeleteArg; 33 using testing::DeleteArg;
33 using testing::InSequence; 34 using testing::InSequence;
34 using testing::Return; 35 using testing::Return;
35 using testing::SaveArg; 36 using testing::SaveArg;
36 37
37 namespace extensions { 38 namespace extensions {
38 39
39 // Base class for tests. 40 // Base class for tests.
40 class MenuManagerTest : public testing::Test { 41 class MenuManagerTest : public testing::Test {
41 public: 42 public:
42 MenuManagerTest() : ui_thread_(BrowserThread::UI, &message_loop_), 43 MenuManagerTest() : ui_thread_(BrowserThread::UI, &message_loop_),
43 file_thread_(BrowserThread::FILE, &message_loop_), 44 file_thread_(BrowserThread::FILE, &message_loop_),
44 manager_(&profile_), 45 manager_(&profile_),
46 prefs_(message_loop_.message_loop_proxy()),
45 next_id_(1) { 47 next_id_(1) {
46 } 48 }
47 49
50 virtual void TearDown() OVERRIDE {
51 prefs_.pref_service()->CommitPendingWrite();
52 message_loop_.RunAllPending();
53 }
54
48 // Returns a test item. 55 // Returns a test item.
49 MenuItem* CreateTestItem(Extension* extension) { 56 MenuItem* CreateTestItem(Extension* extension) {
50 MenuItem::Type type = MenuItem::NORMAL; 57 MenuItem::Type type = MenuItem::NORMAL;
51 MenuItem::ContextList contexts(MenuItem::ALL); 58 MenuItem::ContextList contexts(MenuItem::ALL);
52 MenuItem::Id id(false, extension->id()); 59 MenuItem::Id id(false, extension->id());
53 id.uid = next_id_++; 60 id.uid = next_id_++;
54 return new MenuItem(id, "test", false, true, type, contexts); 61 return new MenuItem(id, "test", false, true, type, contexts);
55 } 62 }
56 63
57 // Returns a test item with the given string ID. 64 // Returns a test item with the given string ID.
(...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 ASSERT_TRUE(child1->checked()); 692 ASSERT_TRUE(child1->checked());
686 693
687 // Removing |parent| should cause only |child1| to be selected. 694 // Removing |parent| should cause only |child1| to be selected.
688 manager_.RemoveContextMenuItem(parent->id()); 695 manager_.RemoveContextMenuItem(parent->id());
689 parent = NULL; 696 parent = NULL;
690 ASSERT_FALSE(new_item->checked()); 697 ASSERT_FALSE(new_item->checked());
691 ASSERT_TRUE(child1->checked()); 698 ASSERT_TRUE(child1->checked());
692 } 699 }
693 700
694 } // namespace extensions 701 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698