| OLD | NEW |
| 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" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 | 84 |
| 85 // Updated to the script shared memory when we get notified. | 85 // Updated to the script shared memory when we get notified. |
| 86 base::SharedMemory* shared_memory_; | 86 base::SharedMemory* shared_memory_; |
| 87 }; | 87 }; |
| 88 | 88 |
| 89 // Test that we get notified even when there are no scripts. | 89 // Test that we get notified even when there are no scripts. |
| 90 TEST_F(UserScriptMasterTest, NoScripts) { | 90 TEST_F(UserScriptMasterTest, NoScripts) { |
| 91 TestingProfile profile; | 91 TestingProfile profile; |
| 92 scoped_refptr<UserScriptMaster> master(new UserScriptMaster(&profile)); | 92 scoped_refptr<UserScriptMaster> master(new UserScriptMaster(&profile)); |
| 93 master->StartLoad(); | 93 master->StartLoad(); |
| 94 message_loop_.PostTask(FROM_HERE, new MessageLoop::QuitTask); | 94 message_loop_.PostTask(FROM_HERE, MessageLoop::QuitClosure); |
| 95 message_loop_.Run(); | 95 message_loop_.Run(); |
| 96 | 96 |
| 97 ASSERT_TRUE(shared_memory_ != NULL); | 97 ASSERT_TRUE(shared_memory_ != NULL); |
| 98 } | 98 } |
| 99 | 99 |
| 100 TEST_F(UserScriptMasterTest, Parse1) { | 100 TEST_F(UserScriptMasterTest, Parse1) { |
| 101 const std::string text( | 101 const std::string text( |
| 102 "// This is my awesome script\n" | 102 "// This is my awesome script\n" |
| 103 "// It does stuff.\n" | 103 "// It does stuff.\n" |
| 104 "// ==UserScript== trailing garbage\n" | 104 "// ==UserScript== trailing garbage\n" |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 user_scripts.push_back(user_script); | 245 user_scripts.push_back(user_script); |
| 246 | 246 |
| 247 UserScriptMaster::ScriptReloader* script_reloader = | 247 UserScriptMaster::ScriptReloader* script_reloader = |
| 248 new UserScriptMaster::ScriptReloader(NULL); | 248 new UserScriptMaster::ScriptReloader(NULL); |
| 249 script_reloader->AddRef(); | 249 script_reloader->AddRef(); |
| 250 script_reloader->LoadUserScripts(&user_scripts); | 250 script_reloader->LoadUserScripts(&user_scripts); |
| 251 script_reloader->Release(); | 251 script_reloader->Release(); |
| 252 | 252 |
| 253 EXPECT_EQ(content, user_scripts[0].js_scripts()[0].GetContent().as_string()); | 253 EXPECT_EQ(content, user_scripts[0].js_scripts()[0].GetContent().as_string()); |
| 254 } | 254 } |
| OLD | NEW |