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

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

Issue 7327007: Moving notification types which are chrome specific to a new header file chrome_notification_type... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/browser/extensions/user_script_master.h" 5 #include "chrome/browser/extensions/user_script_master.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
11 #include "base/message_loop.h" 11 #include "base/message_loop.h"
12 #include "base/path_service.h" 12 #include "base/path_service.h"
13 #include "base/scoped_temp_dir.h" 13 #include "base/scoped_temp_dir.h"
14 #include "base/string_util.h" 14 #include "base/string_util.h"
15 #include "chrome/common/chrome_notification_types.h"
15 #include "chrome/test/testing_profile.h" 16 #include "chrome/test/testing_profile.h"
16 #include "content/browser/browser_thread.h" 17 #include "content/browser/browser_thread.h"
17 #include "content/common/notification_registrar.h" 18 #include "content/common/notification_registrar.h"
18 #include "content/common/notification_service.h" 19 #include "content/common/notification_service.h"
19 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
20 21
21 // Test bringing up a master on a specific directory, putting a script 22 // Test bringing up a master on a specific directory, putting a script
22 // in there, etc. 23 // in there, etc.
23 24
24 class UserScriptMasterTest : public testing::Test, 25 class UserScriptMasterTest : public testing::Test,
25 public NotificationObserver { 26 public NotificationObserver {
26 public: 27 public:
27 UserScriptMasterTest() 28 UserScriptMasterTest()
28 : message_loop_(MessageLoop::TYPE_UI), 29 : message_loop_(MessageLoop::TYPE_UI),
29 shared_memory_(NULL) { 30 shared_memory_(NULL) {
30 } 31 }
31 32
32 virtual void SetUp() { 33 virtual void SetUp() {
33 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 34 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
34 35
35 // Register for all user script notifications. 36 // Register for all user script notifications.
36 registrar_.Add(this, NotificationType::USER_SCRIPTS_UPDATED, 37 registrar_.Add(this, chrome::NOTIFICATION_USER_SCRIPTS_UPDATED,
37 NotificationService::AllSources()); 38 NotificationService::AllSources());
38 39
39 // UserScriptMaster posts tasks to the file thread so make the current 40 // UserScriptMaster posts tasks to the file thread so make the current
40 // thread look like one. 41 // thread look like one.
41 file_thread_.reset(new BrowserThread( 42 file_thread_.reset(new BrowserThread(
42 BrowserThread::FILE, MessageLoop::current())); 43 BrowserThread::FILE, MessageLoop::current()));
43 ui_thread_.reset(new BrowserThread( 44 ui_thread_.reset(new BrowserThread(
44 BrowserThread::UI, MessageLoop::current())); 45 BrowserThread::UI, MessageLoop::current()));
45 } 46 }
46 47
47 virtual void TearDown() { 48 virtual void TearDown() {
48 file_thread_.reset(); 49 file_thread_.reset();
49 ui_thread_.reset(); 50 ui_thread_.reset();
50 } 51 }
51 52
52 virtual void Observe(NotificationType type, 53 virtual void Observe(int type,
53 const NotificationSource& source, 54 const NotificationSource& source,
54 const NotificationDetails& details) { 55 const NotificationDetails& details) {
55 DCHECK(type == NotificationType::USER_SCRIPTS_UPDATED); 56 DCHECK(type == chrome::NOTIFICATION_USER_SCRIPTS_UPDATED);
56 57
57 shared_memory_ = Details<base::SharedMemory>(details).ptr(); 58 shared_memory_ = Details<base::SharedMemory>(details).ptr();
58 if (MessageLoop::current() == &message_loop_) 59 if (MessageLoop::current() == &message_loop_)
59 MessageLoop::current()->Quit(); 60 MessageLoop::current()->Quit();
60 } 61 }
61 62
62 // Directory containing user scripts. 63 // Directory containing user scripts.
63 ScopedTempDir temp_dir_; 64 ScopedTempDir temp_dir_;
64 65
65 NotificationRegistrar registrar_; 66 NotificationRegistrar registrar_;
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 user_script.js_scripts().push_back(UserScript::File( 226 user_script.js_scripts().push_back(UserScript::File(
226 temp_dir_.path(), path.BaseName(), GURL())); 227 temp_dir_.path(), path.BaseName(), GURL()));
227 228
228 UserScriptList user_scripts; 229 UserScriptList user_scripts;
229 user_scripts.push_back(user_script); 230 user_scripts.push_back(user_script);
230 231
231 UserScriptMaster::ScriptReloader::LoadUserScripts(&user_scripts); 232 UserScriptMaster::ScriptReloader::LoadUserScripts(&user_scripts);
232 233
233 EXPECT_EQ(content, user_scripts[0].js_scripts()[0].GetContent().as_string()); 234 EXPECT_EQ(content, user_scripts[0].js_scripts()[0].GetContent().as_string());
234 } 235 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/user_script_master.cc ('k') | chrome/browser/external_tab_container_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698