| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/memory/ref_counted_memory.h" | 6 #include "base/memory/ref_counted_memory.h" |
| 7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
| 8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
| 9 #include "chrome/browser/ui/webui/theme_source.h" | 9 #include "chrome/browser/ui/webui/theme_source.h" |
| 10 #include "chrome/common/url_constants.h" | 10 #include "chrome/common/url_constants.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 ThemeSource* theme_source() const { return theme_source_.get(); } | 25 ThemeSource* theme_source() const { return theme_source_.get(); } |
| 26 size_t result_data_size() const { return result_data_size_; } | 26 size_t result_data_size() const { return result_data_size_; } |
| 27 | 27 |
| 28 void StartDataRequest(const std::string& source) { | 28 void StartDataRequest(const std::string& source) { |
| 29 theme_source()->StartDataRequest(source, -1, -1, callback_); | 29 theme_source()->StartDataRequest(source, -1, -1, callback_); |
| 30 } | 30 } |
| 31 | 31 |
| 32 size_t result_data_size_; | 32 size_t result_data_size_; |
| 33 | 33 |
| 34 private: | 34 private: |
| 35 virtual void SetUp() { | 35 void SetUp() override { |
| 36 profile_.reset(new TestingProfile()); | 36 profile_.reset(new TestingProfile()); |
| 37 theme_source_.reset(new ThemeSource(profile_.get())); | 37 theme_source_.reset(new ThemeSource(profile_.get())); |
| 38 callback_ = base::Bind(&WebUISourcesTest::SendResponse, | 38 callback_ = base::Bind(&WebUISourcesTest::SendResponse, |
| 39 base::Unretained(this)); | 39 base::Unretained(this)); |
| 40 } | 40 } |
| 41 | 41 |
| 42 virtual void TearDown() { | 42 void TearDown() override { |
| 43 theme_source_.reset(); | 43 theme_source_.reset(); |
| 44 profile_.reset(); | 44 profile_.reset(); |
| 45 } | 45 } |
| 46 | 46 |
| 47 void SendResponse(base::RefCountedMemory* data) { | 47 void SendResponse(base::RefCountedMemory* data) { |
| 48 result_data_size_ = data ? data->size() : 0; | 48 result_data_size_ = data ? data->size() : 0; |
| 49 } | 49 } |
| 50 | 50 |
| 51 content::URLDataSource::GotDataCallback callback_; | 51 content::URLDataSource::GotDataCallback callback_; |
| 52 | 52 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 StartDataRequest("css/new_tab_theme.css"); | 87 StartDataRequest("css/new_tab_theme.css"); |
| 88 EXPECT_NE(result_data_size_, empty_size); | 88 EXPECT_NE(result_data_size_, empty_size); |
| 89 | 89 |
| 90 StartDataRequest("css/new_tab_theme.css?pie"); | 90 StartDataRequest("css/new_tab_theme.css?pie"); |
| 91 EXPECT_NE(result_data_size_, empty_size); | 91 EXPECT_NE(result_data_size_, empty_size); |
| 92 | 92 |
| 93 // Check that we send NULL back when we can't find what we're looking for. | 93 // Check that we send NULL back when we can't find what we're looking for. |
| 94 StartDataRequest("css/WRONGURL"); | 94 StartDataRequest("css/WRONGURL"); |
| 95 EXPECT_EQ(result_data_size_, empty_size); | 95 EXPECT_EQ(result_data_size_, empty_size); |
| 96 } | 96 } |
| OLD | NEW |