OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/browser_theme_provider.h" | 5 #include "chrome/browser/browser_theme_provider.h" |
6 #include "chrome/browser/dom_ui/dom_ui_theme_source.h" | 6 #include "chrome/browser/dom_ui/dom_ui_theme_source.h" |
7 #include "chrome/browser/profile.h" | 7 #include "chrome/browser/profile.h" |
8 #include "chrome/common/url_constants.h" | 8 #include "chrome/common/url_constants.h" |
9 #include "chrome/test/testing_profile.h" | 9 #include "chrome/test/testing_profile.h" |
10 #include "grit/theme_resources.h" | 10 #include "grit/theme_resources.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
12 | 12 |
13 // A mock ThemeSource (so we can override SendResponse to get at its data). | 13 // A mock ThemeSource (so we can override SendResponse to get at its data). |
14 class MockThemeSource : public DOMUIThemeSource { | 14 class MockThemeSource : public DOMUIThemeSource { |
15 public: | 15 public: |
16 explicit MockThemeSource(Profile* profile) | 16 explicit MockThemeSource(Profile* profile) |
17 : DOMUIThemeSource(profile), | 17 : DOMUIThemeSource(profile), |
18 result_request_id_(-1), | 18 result_request_id_(-1), |
19 result_data_size_(0) { | 19 result_data_size_(0) { |
20 } | 20 } |
21 | 21 |
22 virtual void SendResponse(int request_id, RefCountedBytes* data) { | 22 virtual void SendResponse(int request_id, RefCountedMemory* data) { |
23 result_data_size_ = data ? data->data.size() : 0; | 23 result_data_size_ = data ? data->size() : 0; |
24 result_request_id_ = request_id; | 24 result_request_id_ = request_id; |
25 } | 25 } |
26 | 26 |
27 int result_request_id_; | 27 int result_request_id_; |
28 size_t result_data_size_; | 28 size_t result_data_size_; |
29 }; | 29 }; |
30 | 30 |
31 class DOMUISourcesTest : public testing::Test { | 31 class DOMUISourcesTest : public testing::Test { |
32 public: | 32 public: |
33 TestingProfile* profile() const { return profile_.get(); } | 33 TestingProfile* profile() const { return profile_.get(); } |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 | 80 |
81 theme_source()->StartDataRequest("css/newtab.css?pie", 3); | 81 theme_source()->StartDataRequest("css/newtab.css?pie", 3); |
82 EXPECT_EQ(theme_source()->result_request_id_, 3); | 82 EXPECT_EQ(theme_source()->result_request_id_, 3); |
83 EXPECT_NE(theme_source()->result_data_size_, empty_size); | 83 EXPECT_NE(theme_source()->result_data_size_, empty_size); |
84 | 84 |
85 // Check that we send NULL back when we can't find what we're looking for. | 85 // Check that we send NULL back when we can't find what we're looking for. |
86 theme_source()->StartDataRequest("css/WRONGURL", 7); | 86 theme_source()->StartDataRequest("css/WRONGURL", 7); |
87 EXPECT_EQ(theme_source()->result_request_id_, 7); | 87 EXPECT_EQ(theme_source()->result_request_id_, 7); |
88 EXPECT_EQ(theme_source()->result_data_size_, empty_size); | 88 EXPECT_EQ(theme_source()->result_data_size_, empty_size); |
89 } | 89 } |
OLD | NEW |