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 "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_util.h" | 9 #include "base/file_util.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 class UserScriptMasterTest : public testing::Test, | 39 class UserScriptMasterTest : public testing::Test, |
40 public content::NotificationObserver { | 40 public content::NotificationObserver { |
41 public: | 41 public: |
42 UserScriptMasterTest() : shared_memory_(NULL) { | 42 UserScriptMasterTest() : shared_memory_(NULL) { |
43 } | 43 } |
44 | 44 |
45 virtual void SetUp() { | 45 virtual void SetUp() { |
46 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 46 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
47 | 47 |
48 // Register for all user script notifications. | 48 // Register for all user script notifications. |
49 registrar_.Add(this, chrome::NOTIFICATION_USER_SCRIPTS_UPDATED, | 49 registrar_.Add(this, |
| 50 extensions::NOTIFICATION_USER_SCRIPTS_UPDATED, |
50 content::NotificationService::AllSources()); | 51 content::NotificationService::AllSources()); |
51 | 52 |
52 // UserScriptMaster posts tasks to the file thread so make the current | 53 // UserScriptMaster posts tasks to the file thread so make the current |
53 // thread look like one. | 54 // thread look like one. |
54 file_thread_.reset(new content::TestBrowserThread( | 55 file_thread_.reset(new content::TestBrowserThread( |
55 BrowserThread::FILE, base::MessageLoop::current())); | 56 BrowserThread::FILE, base::MessageLoop::current())); |
56 ui_thread_.reset(new content::TestBrowserThread( | 57 ui_thread_.reset(new content::TestBrowserThread( |
57 BrowserThread::UI, base::MessageLoop::current())); | 58 BrowserThread::UI, base::MessageLoop::current())); |
58 } | 59 } |
59 | 60 |
60 virtual void TearDown() { | 61 virtual void TearDown() { |
61 file_thread_.reset(); | 62 file_thread_.reset(); |
62 ui_thread_.reset(); | 63 ui_thread_.reset(); |
63 } | 64 } |
64 | 65 |
65 virtual void Observe(int type, | 66 virtual void Observe(int type, |
66 const content::NotificationSource& source, | 67 const content::NotificationSource& source, |
67 const content::NotificationDetails& details) OVERRIDE { | 68 const content::NotificationDetails& details) OVERRIDE { |
68 DCHECK(type == chrome::NOTIFICATION_USER_SCRIPTS_UPDATED); | 69 DCHECK(type == extensions::NOTIFICATION_USER_SCRIPTS_UPDATED); |
69 | 70 |
70 shared_memory_ = content::Details<base::SharedMemory>(details).ptr(); | 71 shared_memory_ = content::Details<base::SharedMemory>(details).ptr(); |
71 if (base::MessageLoop::current() == &message_loop_) | 72 if (base::MessageLoop::current() == &message_loop_) |
72 base::MessageLoop::current()->Quit(); | 73 base::MessageLoop::current()->Quit(); |
73 } | 74 } |
74 | 75 |
75 // Directory containing user scripts. | 76 // Directory containing user scripts. |
76 base::ScopedTempDir temp_dir_; | 77 base::ScopedTempDir temp_dir_; |
77 | 78 |
78 content::NotificationRegistrar registrar_; | 79 content::NotificationRegistrar registrar_; |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 | 254 |
254 UserScriptList user_scripts; | 255 UserScriptList user_scripts; |
255 user_scripts.push_back(user_script); | 256 user_scripts.push_back(user_script); |
256 | 257 |
257 UserScriptMaster::LoadScriptsForTest(&user_scripts); | 258 UserScriptMaster::LoadScriptsForTest(&user_scripts); |
258 | 259 |
259 EXPECT_EQ(content, user_scripts[0].js_scripts()[0].GetContent().as_string()); | 260 EXPECT_EQ(content, user_scripts[0].js_scripts()[0].GetContent().as_string()); |
260 } | 261 } |
261 | 262 |
262 } // namespace extensions | 263 } // namespace extensions |
OLD | NEW |