| 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" |
| 11 #include "base/files/scoped_temp_dir.h" | 11 #include "base/files/scoped_temp_dir.h" |
| 12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
| 13 #include "base/path_service.h" | 13 #include "base/path_service.h" |
| 14 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
| 15 #include "chrome/browser/chrome_notification_types.h" | 15 #include "chrome/browser/chrome_notification_types.h" |
| 16 #include "chrome/browser/extensions/shared_user_script_master.h" |
| 16 #include "chrome/test/base/testing_profile.h" | 17 #include "chrome/test/base/testing_profile.h" |
| 18 #include "content/public/browser/notification_observer.h" |
| 17 #include "content/public/browser/notification_registrar.h" | 19 #include "content/public/browser/notification_registrar.h" |
| 18 #include "content/public/browser/notification_service.h" | 20 #include "content/public/browser/notification_service.h" |
| 19 #include "content/public/test/test_browser_thread.h" | 21 #include "content/public/test/test_browser_thread.h" |
| 20 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
| 21 | 23 |
| 22 using content::BrowserThread; | 24 using content::BrowserThread; |
| 23 using extensions::URLPatternSet; | 25 using extensions::URLPatternSet; |
| 24 | 26 |
| 25 namespace { | 27 namespace { |
| 26 | 28 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 scoped_ptr<content::TestBrowserThread> file_thread_; | 85 scoped_ptr<content::TestBrowserThread> file_thread_; |
| 84 scoped_ptr<content::TestBrowserThread> ui_thread_; | 86 scoped_ptr<content::TestBrowserThread> ui_thread_; |
| 85 | 87 |
| 86 // Updated to the script shared memory when we get notified. | 88 // Updated to the script shared memory when we get notified. |
| 87 base::SharedMemory* shared_memory_; | 89 base::SharedMemory* shared_memory_; |
| 88 }; | 90 }; |
| 89 | 91 |
| 90 // Test that we get notified even when there are no scripts. | 92 // Test that we get notified even when there are no scripts. |
| 91 TEST_F(UserScriptMasterTest, NoScripts) { | 93 TEST_F(UserScriptMasterTest, NoScripts) { |
| 92 TestingProfile profile; | 94 TestingProfile profile; |
| 93 UserScriptMaster master(&profile); | 95 SharedUserScriptMaster master(&profile); |
| 94 master.StartLoad(); | 96 master.StartLoad(); |
| 95 message_loop_.PostTask(FROM_HERE, base::MessageLoop::QuitClosure()); | 97 message_loop_.PostTask(FROM_HERE, base::MessageLoop::QuitClosure()); |
| 96 message_loop_.Run(); | 98 message_loop_.Run(); |
| 97 | 99 |
| 98 ASSERT_TRUE(shared_memory_ != NULL); | 100 ASSERT_TRUE(shared_memory_ != NULL); |
| 99 } | 101 } |
| 100 | 102 |
| 101 TEST_F(UserScriptMasterTest, Parse1) { | 103 TEST_F(UserScriptMasterTest, Parse1) { |
| 102 const std::string text( | 104 const std::string text( |
| 103 "// This is my awesome script\n" | 105 "// This is my awesome script\n" |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 | 255 |
| 254 UserScriptList user_scripts; | 256 UserScriptList user_scripts; |
| 255 user_scripts.push_back(user_script); | 257 user_scripts.push_back(user_script); |
| 256 | 258 |
| 257 UserScriptMaster::LoadScriptsForTest(&user_scripts); | 259 UserScriptMaster::LoadScriptsForTest(&user_scripts); |
| 258 | 260 |
| 259 EXPECT_EQ(content, user_scripts[0].js_scripts()[0].GetContent().as_string()); | 261 EXPECT_EQ(content, user_scripts[0].js_scripts()[0].GetContent().as_string()); |
| 260 } | 262 } |
| 261 | 263 |
| 262 } // namespace extensions | 264 } // namespace extensions |
| OLD | NEW |