Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/settings_manage_profile_handler.h" | 5 #include "chrome/browser/ui/webui/settings/settings_manage_profile_handler.h" |
| 6 | 6 |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "chrome/common/pref_names.h" | 8 #include "chrome/common/pref_names.h" |
| 9 #include "chrome/test/base/testing_browser_process.h" | 9 #include "chrome/test/base/testing_browser_process.h" |
| 10 #include "chrome/test/base/testing_profile_manager.h" | 10 #include "chrome/test/base/testing_profile_manager.h" |
| 11 #include "components/prefs/pref_service.h" | 11 #include "components/prefs/pref_service.h" |
| 12 #include "content/public/browser/web_ui_data_source.h" | 12 #include "content/public/browser/web_ui_data_source.h" |
| 13 #include "content/public/test/test_browser_thread_bundle.h" | 13 #include "content/public/test/test_browser_thread_bundle.h" |
| 14 #include "content/public/test/test_web_ui.h" | 14 #include "content/public/test/test_web_ui.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 16 | 16 |
| 17 namespace settings { | 17 namespace settings { |
| 18 | 18 |
| 19 namespace { | 19 namespace { |
| 20 | 20 |
| 21 class TestManageProfileHandler : public ManageProfileHandler { | 21 class TestManageProfileHandler : public ManageProfileHandler { |
| 22 public: | 22 public: |
| 23 explicit TestManageProfileHandler(Profile* profile) | 23 explicit TestManageProfileHandler(Profile* profile) |
| 24 : ManageProfileHandler(profile) {} | 24 : ManageProfileHandler(profile) {} |
| 25 | 25 |
| 26 using ManageProfileHandler::set_web_ui; | 26 using ManageProfileHandler::set_web_ui; |
|
Dan Beam
2016/05/19 03:36:54
using ManageProfileHandler::AllowJavascript;
tommycli
2016/05/19 19:27:15
Done.
| |
| 27 }; | 27 }; |
| 28 | 28 |
| 29 } // namespace | 29 } // namespace |
| 30 | 30 |
| 31 class ManageProfileHandlerTest : public testing::Test { | 31 class ManageProfileHandlerTest : public testing::Test { |
| 32 public: | 32 public: |
| 33 ManageProfileHandlerTest() | 33 ManageProfileHandlerTest() |
| 34 : profile_manager_(TestingBrowserProcess::GetGlobal()), | 34 : profile_manager_(TestingBrowserProcess::GetGlobal()), |
| 35 profile_(nullptr) {} | 35 profile_(nullptr) {} |
| 36 | 36 |
| 37 void SetUp() override { | 37 void SetUp() override { |
| 38 ASSERT_TRUE(profile_manager_.SetUp()); | 38 ASSERT_TRUE(profile_manager_.SetUp()); |
| 39 profile_ = profile_manager_.CreateTestingProfile("Profile 1"); | 39 profile_ = profile_manager_.CreateTestingProfile("Profile 1"); |
| 40 | 40 |
| 41 handler_.reset(new TestManageProfileHandler(profile_)); | 41 handler_.reset(new TestManageProfileHandler(profile_)); |
| 42 handler_->set_web_ui(&web_ui_); | 42 handler_->set_web_ui(&web_ui_); |
| 43 handler()->AllowJavascript(); | |
| 44 web_ui()->ClearTrackedCalls(); | |
| 43 } | 45 } |
| 44 | 46 |
| 45 void VerifyIconList(const base::Value* value) { | 47 void VerifyIconList(const base::Value* value) { |
| 46 const base::ListValue* icon_urls = nullptr; | 48 const base::ListValue* icon_urls = nullptr; |
| 47 ASSERT_TRUE(value->GetAsList(&icon_urls)); | 49 ASSERT_TRUE(value->GetAsList(&icon_urls)); |
| 48 | 50 |
| 49 // Expect the list of icon URLs to be a non-empty list of non-empty strings. | 51 // Expect the list of icon URLs to be a non-empty list of non-empty strings. |
| 50 EXPECT_FALSE(icon_urls->empty()); | 52 EXPECT_FALSE(icon_urls->empty()); |
| 51 for (size_t i = 0; i < icon_urls->GetSize(); ++i) { | 53 for (size_t i = 0; i < icon_urls->GetSize(); ++i) { |
| 52 std::string icon_url; | 54 std::string icon_url; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 109 EXPECT_EQ("cr.webUIListenerCallback", data.function_name()); | 111 EXPECT_EQ("cr.webUIListenerCallback", data.function_name()); |
| 110 | 112 |
| 111 std::string event_id; | 113 std::string event_id; |
| 112 ASSERT_TRUE(data.arg1()->GetAsString(&event_id)); | 114 ASSERT_TRUE(data.arg1()->GetAsString(&event_id)); |
| 113 EXPECT_EQ("available-icons-changed", event_id); | 115 EXPECT_EQ("available-icons-changed", event_id); |
| 114 | 116 |
| 115 VerifyIconList(data.arg2()); | 117 VerifyIconList(data.arg2()); |
| 116 } | 118 } |
| 117 | 119 |
| 118 } // namespace settings | 120 } // namespace settings |
| OLD | NEW |