| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "base/json/json_file_value_serializer.h" | 5 #include "base/json/json_file_value_serializer.h" |
| 6 #include "base/message_loop/message_loop.h" | |
| 7 #include "base/path_service.h" | 6 #include "base/path_service.h" |
| 8 #include "chrome/common/chrome_paths.h" | 7 #include "chrome/common/chrome_paths.h" |
| 9 #include "content/public/test/test_browser_thread.h" | 8 #include "content/public/test/test_browser_thread_bundle.h" |
| 10 #include "extensions/browser/info_map.h" | 9 #include "extensions/browser/info_map.h" |
| 11 #include "extensions/common/extension.h" | 10 #include "extensions/common/extension.h" |
| 12 #include "extensions/common/manifest_constants.h" | 11 #include "extensions/common/manifest_constants.h" |
| 13 #include "extensions/common/permissions/permissions_data.h" | 12 #include "extensions/common/permissions/permissions_data.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 15 | 14 |
| 16 using content::BrowserThread; | |
| 17 | |
| 18 namespace extensions { | 15 namespace extensions { |
| 19 namespace { | 16 namespace { |
| 20 | 17 |
| 21 scoped_refptr<Extension> LoadManifest(const std::string& dir, | 18 scoped_refptr<Extension> LoadManifest(const std::string& dir, |
| 22 const std::string& test_file) { | 19 const std::string& test_file) { |
| 23 base::FilePath path; | 20 base::FilePath path; |
| 24 PathService::Get(chrome::DIR_TEST_DATA, &path); | 21 PathService::Get(chrome::DIR_TEST_DATA, &path); |
| 25 path = path.AppendASCII("extensions").AppendASCII(dir).AppendASCII(test_file); | 22 path = path.AppendASCII("extensions").AppendASCII(dir).AppendASCII(test_file); |
| 26 | 23 |
| 27 JSONFileValueDeserializer deserializer(path); | 24 JSONFileValueDeserializer deserializer(path); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 40 | 37 |
| 41 return extension; | 38 return extension; |
| 42 } | 39 } |
| 43 | 40 |
| 44 } // namespace | 41 } // namespace |
| 45 | 42 |
| 46 // This test lives in Chrome because it depends on hosted app permissions | 43 // This test lives in Chrome because it depends on hosted app permissions |
| 47 // (specifically, notifications) that do not exist in src/extensions. | 44 // (specifically, notifications) that do not exist in src/extensions. |
| 48 class ChromeInfoMapTest : public testing::Test { | 45 class ChromeInfoMapTest : public testing::Test { |
| 49 public: | 46 public: |
| 50 ChromeInfoMapTest() | 47 ChromeInfoMapTest() = default; |
| 51 : ui_thread_(BrowserThread::UI, &message_loop_), | |
| 52 io_thread_(BrowserThread::IO, &message_loop_) {} | |
| 53 | 48 |
| 54 private: | 49 private: |
| 55 base::MessageLoop message_loop_; | 50 content::TestBrowserThreadBundle test_browser_thread_bundle_; |
| 56 content::TestBrowserThread ui_thread_; | |
| 57 content::TestBrowserThread io_thread_; | |
| 58 }; | 51 }; |
| 59 | 52 |
| 60 // Tests API access permissions given both extension and app URLs. | 53 // Tests API access permissions given both extension and app URLs. |
| 61 TEST_F(ChromeInfoMapTest, CheckPermissions) { | 54 TEST_F(ChromeInfoMapTest, CheckPermissions) { |
| 62 scoped_refptr<InfoMap> info_map(new InfoMap()); | 55 scoped_refptr<InfoMap> info_map(new InfoMap()); |
| 63 | 56 |
| 64 scoped_refptr<Extension> app( | 57 scoped_refptr<Extension> app( |
| 65 LoadManifest("manifest_tests", "valid_app.json")); | 58 LoadManifest("manifest_tests", "valid_app.json")); |
| 66 scoped_refptr<Extension> extension( | 59 scoped_refptr<Extension> extension( |
| 67 LoadManifest("manifest_tests", "tabs_extension.json")); | 60 LoadManifest("manifest_tests", "tabs_extension.json")); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 LoadManifest("manifest_tests", "valid_app.json")); | 102 LoadManifest("manifest_tests", "valid_app.json")); |
| 110 info_map->AddExtension(app.get(), base::Time(), false, false); | 103 info_map->AddExtension(app.get(), base::Time(), false, false); |
| 111 | 104 |
| 112 EXPECT_FALSE(info_map->AreNotificationsDisabled(app->id())); | 105 EXPECT_FALSE(info_map->AreNotificationsDisabled(app->id())); |
| 113 info_map->SetNotificationsDisabled(app->id(), true); | 106 info_map->SetNotificationsDisabled(app->id(), true); |
| 114 EXPECT_TRUE(info_map->AreNotificationsDisabled(app->id())); | 107 EXPECT_TRUE(info_map->AreNotificationsDisabled(app->id())); |
| 115 info_map->SetNotificationsDisabled(app->id(), false); | 108 info_map->SetNotificationsDisabled(app->id(), false); |
| 116 } | 109 } |
| 117 | 110 |
| 118 } // namespace extensions | 111 } // namespace extensions |
| OLD | NEW |