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 "components/supervised_user_error_page/supervised_user_error_page.h" | 5 #include "components/supervised_user_error_page/supervised_user_error_page.h" |
6 | 6 |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "components/grit/components_resources.h" | 8 #include "components/grit/components_resources.h" |
9 #include "components/strings/grit/components_strings.h" | 9 #include "components/strings/grit/components_strings.h" |
10 #include "testing/gmock/include/gmock/gmock.h" | 10 #include "testing/gmock/include/gmock/gmock.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 class SupervisedUserErrorPageTest_BuildHtml | 69 class SupervisedUserErrorPageTest_BuildHtml |
70 : public ::testing::TestWithParam<BuildHtmlTestParameter> {}; | 70 : public ::testing::TestWithParam<BuildHtmlTestParameter> {}; |
71 | 71 |
72 TEST_P(SupervisedUserErrorPageTest_BuildHtml, BuildHtml) { | 72 TEST_P(SupervisedUserErrorPageTest_BuildHtml, BuildHtml) { |
73 BuildHtmlTestParameter param = GetParam(); | 73 BuildHtmlTestParameter param = GetParam(); |
74 std::string result = BuildHtml( | 74 std::string result = BuildHtml( |
75 param.allow_access_requests, param.profile_image_url, | 75 param.allow_access_requests, param.profile_image_url, |
76 param.profile_image_url2, param.custodian, param.custodian_email, | 76 param.profile_image_url2, param.custodian, param.custodian_email, |
77 param.second_custodian, param.second_custodian_email, | 77 param.second_custodian, param.second_custodian_email, |
78 param.is_child_account, param.reason, ""); | 78 param.is_child_account, param.reason, ""); |
79 // The result should contain the original HTML plus scripts that plug values | 79 // The result should contain the original HTML (with $i18n{} replacements) |
80 // into it. The test can't easily check that the scripts are correct, but | 80 // plus scripts that plug values into it. The test can't easily check that the |
81 // can check that the output contains the expected values. | 81 // scripts are correct, but can check that the output contains the expected |
82 std::string html = | 82 // values. |
83 ResourceBundle::GetSharedInstance() | |
84 .GetRawDataResource(IDR_SUPERVISED_USER_BLOCK_INTERSTITIAL_HTML) | |
85 .as_string(); | |
86 EXPECT_THAT(result, testing::HasSubstr(html)); | |
87 EXPECT_THAT(result, testing::HasSubstr(param.profile_image_url)); | 83 EXPECT_THAT(result, testing::HasSubstr(param.profile_image_url)); |
88 EXPECT_THAT(result, testing::HasSubstr(param.profile_image_url2)); | 84 EXPECT_THAT(result, testing::HasSubstr(param.profile_image_url2)); |
89 EXPECT_THAT(result, testing::HasSubstr(param.custodian)); | 85 EXPECT_THAT(result, testing::HasSubstr(param.custodian)); |
90 EXPECT_THAT(result, testing::HasSubstr(param.custodian_email)); | 86 EXPECT_THAT(result, testing::HasSubstr(param.custodian_email)); |
91 if (param.has_two_parents) { | 87 if (param.has_two_parents) { |
92 EXPECT_THAT(result, testing::HasSubstr(param.second_custodian)); | 88 EXPECT_THAT(result, testing::HasSubstr(param.second_custodian)); |
93 EXPECT_THAT(result, testing::HasSubstr(param.second_custodian_email)); | 89 EXPECT_THAT(result, testing::HasSubstr(param.second_custodian_email)); |
94 } | 90 } |
95 if (param.reason == ASYNC_CHECKER || param.reason == BLACKLIST) { | 91 if (param.reason == ASYNC_CHECKER || param.reason == BLACKLIST) { |
96 EXPECT_THAT(result, testing::HasSubstr("\"showFeedbackLink\":true")); | 92 EXPECT_THAT(result, testing::HasSubstr("\"showFeedbackLink\":true")); |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 "custodian2_email", false, DEFAULT, true}, | 196 "custodian2_email", false, DEFAULT, true}, |
201 {true, "url1", "url2", "custodian", "custodian_email", "custodian2", | 197 {true, "url1", "url2", "custodian", "custodian_email", "custodian2", |
202 "custodian2_email", true, ASYNC_CHECKER, true}, | 198 "custodian2_email", true, ASYNC_CHECKER, true}, |
203 }; | 199 }; |
204 | 200 |
205 INSTANTIATE_TEST_CASE_P(GetBlockMessageIDParameterized, | 201 INSTANTIATE_TEST_CASE_P(GetBlockMessageIDParameterized, |
206 SupervisedUserErrorPageTest_BuildHtml, | 202 SupervisedUserErrorPageTest_BuildHtml, |
207 ::testing::ValuesIn(build_html_test_parameter)); | 203 ::testing::ValuesIn(build_html_test_parameter)); |
208 | 204 |
209 } // namespace supervised_user_error_page | 205 } // namespace supervised_user_error_page |
OLD | NEW |