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

Side by Side Diff: chrome/browser/ui/webui/settings/site_settings_handler_unittest.cc

Issue 2679453002: MD Settings: CrOS: Use correct profile for Guest mode content settings (Closed)
Patch Set: Fix unittests Created 3 years, 10 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
« no previous file with comments | « chrome/browser/ui/webui/settings/site_settings_handler.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/ui/webui/settings/site_settings_handler.h" 5 #include "chrome/browser/ui/webui/settings/site_settings_handler.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "chrome/browser/chrome_notification_types.h" 9 #include "chrome/browser/chrome_notification_types.h"
10 #include "chrome/browser/ui/webui/site_settings_helper.h" 10 #include "chrome/browser/ui/webui/site_settings_helper.h"
11 #include "chrome/test/base/testing_profile.h" 11 #include "chrome/test/base/testing_profile.h"
12 #include "components/content_settings/core/common/content_settings.h" 12 #include "components/content_settings/core/common/content_settings.h"
13 #include "components/content_settings/core/common/content_settings_types.h" 13 #include "components/content_settings/core/common/content_settings_types.h"
14 #include "content/public/browser/notification_service.h" 14 #include "content/public/browser/notification_service.h"
15 #include "content/public/browser/web_ui_data_source.h" 15 #include "content/public/browser/web_ui_data_source.h"
16 #include "content/public/test/test_browser_thread_bundle.h" 16 #include "content/public/test/test_browser_thread_bundle.h"
17 #include "content/public/test/test_web_ui.h" 17 #include "content/public/test/test_web_ui.h"
18 #include "extensions/common/extension_builder.h" 18 #include "extensions/common/extension_builder.h"
19 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
20 20
21 #if defined(OS_CHROMEOS)
22 #include "chrome/browser/chromeos/login/users/mock_user_manager.h"
23 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h"
24 #endif
25
21 namespace { 26 namespace {
22 27
23 const char kCallbackId[] = "test-callback-id"; 28 const char kCallbackId[] = "test-callback-id";
24 const char kSetting[] = "setting"; 29 const char kSetting[] = "setting";
25 const char kSource[] = "source"; 30 const char kSource[] = "source";
26 31
27 } 32 }
28 33
29 namespace settings { 34 namespace settings {
30 35
31 class SiteSettingsHandlerTest : public testing::Test { 36 class SiteSettingsHandlerTest : public testing::Test {
32 public: 37 public:
33 SiteSettingsHandlerTest() : handler_(&profile_) {} 38 SiteSettingsHandlerTest() : handler_(&profile_) {
39 #if defined(OS_CHROMEOS)
40 mock_user_manager_ = new chromeos::MockUserManager;
41 user_manager_enabler_.reset(
42 new chromeos::ScopedUserManagerEnabler(mock_user_manager_));
43 #endif
44 }
34 45
35 void SetUp() override { 46 void SetUp() override {
36 handler()->set_web_ui(web_ui()); 47 handler()->set_web_ui(web_ui());
37 handler()->AllowJavascript(); 48 handler()->AllowJavascript();
38 web_ui()->ClearTrackedCalls(); 49 web_ui()->ClearTrackedCalls();
39 } 50 }
40 51
41 Profile* profile() { return &profile_; } 52 Profile* profile() { return &profile_; }
42 content::TestWebUI* web_ui() { return &web_ui_; } 53 content::TestWebUI* web_ui() { return &web_ui_; }
43 SiteSettingsHandler* handler() { return &handler_; } 54 SiteSettingsHandler* handler() { return &handler_; }
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 ASSERT_FALSE(profile_.HasOffTheRecordProfile()); 216 ASSERT_FALSE(profile_.HasOffTheRecordProfile());
206 incognito_profile_ = nullptr; 217 incognito_profile_ = nullptr;
207 } 218 }
208 219
209 private: 220 private:
210 content::TestBrowserThreadBundle thread_bundle_; 221 content::TestBrowserThreadBundle thread_bundle_;
211 TestingProfile profile_; 222 TestingProfile profile_;
212 TestingProfile* incognito_profile_; 223 TestingProfile* incognito_profile_;
213 content::TestWebUI web_ui_; 224 content::TestWebUI web_ui_;
214 SiteSettingsHandler handler_; 225 SiteSettingsHandler handler_;
226 #if defined(OS_CHROMEOS)
227 chromeos::MockUserManager* mock_user_manager_; // Not owned.
228 std::unique_ptr<chromeos::ScopedUserManagerEnabler> user_manager_enabler_;
229 #endif
215 }; 230 };
216 231
217 TEST_F(SiteSettingsHandlerTest, GetAndSetDefault) { 232 TEST_F(SiteSettingsHandlerTest, GetAndSetDefault) {
218 // Test the JS -> C++ -> JS callback path for getting and setting defaults. 233 // Test the JS -> C++ -> JS callback path for getting and setting defaults.
219 base::ListValue getArgs; 234 base::ListValue getArgs;
220 getArgs.AppendString(kCallbackId); 235 getArgs.AppendString(kCallbackId);
221 getArgs.AppendString("notifications"); 236 getArgs.AppendString("notifications");
222 handler()->HandleGetDefaultValueForContentType(&getArgs); 237 handler()->HandleGetDefaultValueForContentType(&getArgs);
223 ValidateDefault("ask", "default", 1U); 238 ValidateDefault("ask", "default", 1U);
224 239
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 args.AppendString("http://www.google.com"); 383 args.AppendString("http://www.google.com");
369 handler()->HandleRemoveZoomLevel(&args); 384 handler()->HandleRemoveZoomLevel(&args);
370 ValidateZoom("", "", 3U); 385 ValidateZoom("", "", 3U);
371 386
372 double default_level = host_zoom_map->GetDefaultZoomLevel(); 387 double default_level = host_zoom_map->GetDefaultZoomLevel();
373 double level = host_zoom_map->GetZoomLevelForHostAndScheme("http", host); 388 double level = host_zoom_map->GetZoomLevelForHostAndScheme("http", host);
374 EXPECT_EQ(default_level, level); 389 EXPECT_EQ(default_level, level);
375 } 390 }
376 391
377 } // namespace settings 392 } // namespace settings
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/settings/site_settings_handler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698