| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "chrome/browser/profile_resetter/profile_resetter.h" | 9 #include "chrome/browser/profile_resetter/profile_resetter.h" |
| 10 #include "chrome/browser/ui/webui/settings/reset_settings_handler.h" | 10 #include "chrome/browser/ui/webui/settings/reset_settings_handler.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 return resets_; | 40 return resets_; |
| 41 } | 41 } |
| 42 | 42 |
| 43 private: | 43 private: |
| 44 size_t resets_ = 0; | 44 size_t resets_ = 0; |
| 45 }; | 45 }; |
| 46 | 46 |
| 47 class TestingResetSettingsHandler : public ResetSettingsHandler { | 47 class TestingResetSettingsHandler : public ResetSettingsHandler { |
| 48 public: | 48 public: |
| 49 TestingResetSettingsHandler( | 49 TestingResetSettingsHandler( |
| 50 TestingProfile* profile, bool allow_powerwash, content::WebUI* web_ui) | 50 TestingProfile* profile, content::WebUI* web_ui) |
| 51 : ResetSettingsHandler(profile, allow_powerwash), | 51 : ResetSettingsHandler(profile), |
| 52 resetter_(profile) { | 52 resetter_(profile) { |
| 53 set_web_ui(web_ui); | 53 set_web_ui(web_ui); |
| 54 } | 54 } |
| 55 | 55 |
| 56 size_t resets() const { return resetter_.resets(); } | 56 size_t resets() const { return resetter_.resets(); } |
| 57 | 57 |
| 58 using settings::ResetSettingsHandler::HandleResetProfileSettings; | 58 using settings::ResetSettingsHandler::HandleResetProfileSettings; |
| 59 | 59 |
| 60 protected: | 60 protected: |
| 61 ProfileResetter* GetResetter() override { | 61 ProfileResetter* GetResetter() override { |
| 62 return &resetter_; | 62 return &resetter_; |
| 63 } | 63 } |
| 64 | 64 |
| 65 private: | 65 private: |
| 66 MockProfileResetter resetter_; | 66 MockProfileResetter resetter_; |
| 67 | 67 |
| 68 DISALLOW_COPY_AND_ASSIGN(TestingResetSettingsHandler); | 68 DISALLOW_COPY_AND_ASSIGN(TestingResetSettingsHandler); |
| 69 }; | 69 }; |
| 70 | 70 |
| 71 class ResetSettingsHandlerTest : public testing::Test { | 71 class ResetSettingsHandlerTest : public testing::Test { |
| 72 public: | 72 public: |
| 73 ResetSettingsHandlerTest() : handler_(&profile_, false, &web_ui_) { | 73 ResetSettingsHandlerTest() : handler_(&profile_, &web_ui_) { |
| 74 } | 74 } |
| 75 | 75 |
| 76 TestingResetSettingsHandler* handler() { return &handler_; } | 76 TestingResetSettingsHandler* handler() { return &handler_; } |
| 77 content::TestWebUI* web_ui() { return &web_ui_; } | 77 content::TestWebUI* web_ui() { return &web_ui_; } |
| 78 | 78 |
| 79 private: | 79 private: |
| 80 // The order here matters. | 80 // The order here matters. |
| 81 content::TestBrowserThreadBundle thread_bundle_; | 81 content::TestBrowserThreadBundle thread_bundle_; |
| 82 TestingProfile profile_; | 82 TestingProfile profile_; |
| 83 content::TestWebUI web_ui_; | 83 content::TestWebUI web_ui_; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 94 EXPECT_EQ(1u, handler()->resets()); | 94 EXPECT_EQ(1u, handler()->resets()); |
| 95 // Check that Javascript side is notified after resetting is done. | 95 // Check that Javascript side is notified after resetting is done. |
| 96 EXPECT_EQ("cr.webUIResponse", | 96 EXPECT_EQ("cr.webUIResponse", |
| 97 web_ui()->call_data()[0]->function_name()); | 97 web_ui()->call_data()[0]->function_name()); |
| 98 std::string callback_id; | 98 std::string callback_id; |
| 99 EXPECT_TRUE(web_ui()->call_data()[0]->arg1()->GetAsString(&callback_id)); | 99 EXPECT_TRUE(web_ui()->call_data()[0]->arg1()->GetAsString(&callback_id)); |
| 100 EXPECT_EQ(expected_callback_id, callback_id); | 100 EXPECT_EQ(expected_callback_id, callback_id); |
| 101 } | 101 } |
| 102 | 102 |
| 103 } // namespace | 103 } // namespace |
| OLD | NEW |