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/memory/ref_counted_memory.h" | 5 #include "base/memory/ref_counted_memory.h" |
6 #include "base/message_loop.h" | 6 #include "base/message_loop.h" |
7 #include "chrome/browser/profiles/profile.h" | 7 #include "chrome/browser/profiles/profile.h" |
8 #include "chrome/browser/ui/webui/theme_source.h" | 8 #include "chrome/browser/ui/webui/theme_source.h" |
9 #include "chrome/common/url_constants.h" | 9 #include "chrome/common/url_constants.h" |
10 #include "chrome/test/base/testing_profile.h" | 10 #include "chrome/test/base/testing_profile.h" |
11 #include "content/test/test_browser_thread.h" | 11 #include "content/test/test_browser_thread.h" |
12 #include "grit/theme_resources.h" | 12 #include "grit/theme_resources.h" |
13 #include "grit/theme_resources_standard.h" | 13 #include "grit/theme_resources_standard.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
15 | 15 |
16 using content::BrowserThread; | 16 using content::BrowserThread; |
17 | 17 |
18 // A mock ThemeSource (so we can override SendResponse to get at its data). | 18 // A mock ThemeSource (so we can override SendResponse to get at its data). |
19 class MockThemeSource : public ThemeSource { | 19 class MockThemeSource : public ThemeSource { |
20 public: | 20 public: |
21 explicit MockThemeSource(Profile* profile) | 21 explicit MockThemeSource(Profile* profile) |
22 : ThemeSource(profile), | 22 : ThemeSource(profile), |
23 result_request_id_(-1), | 23 result_request_id_(-1), |
24 result_data_size_(0) { | 24 result_data_size_(0) { |
25 } | 25 } |
26 | 26 |
27 virtual void SendResponse(int request_id, RefCountedMemory* data) { | 27 virtual void SendResponse(int request_id, base::RefCountedMemory* data) { |
28 result_data_size_ = data ? data->size() : 0; | 28 result_data_size_ = data ? data->size() : 0; |
29 result_request_id_ = request_id; | 29 result_request_id_ = request_id; |
30 } | 30 } |
31 | 31 |
32 int result_request_id_; | 32 int result_request_id_; |
33 size_t result_data_size_; | 33 size_t result_data_size_; |
34 | 34 |
35 private: | 35 private: |
36 ~MockThemeSource() {} | 36 ~MockThemeSource() {} |
37 }; | 37 }; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 | 95 |
96 theme_source()->StartDataRequest("css/new_tab_theme.css?pie", false, 3); | 96 theme_source()->StartDataRequest("css/new_tab_theme.css?pie", false, 3); |
97 EXPECT_EQ(theme_source()->result_request_id_, 3); | 97 EXPECT_EQ(theme_source()->result_request_id_, 3); |
98 EXPECT_NE(theme_source()->result_data_size_, empty_size); | 98 EXPECT_NE(theme_source()->result_data_size_, empty_size); |
99 | 99 |
100 // Check that we send NULL back when we can't find what we're looking for. | 100 // Check that we send NULL back when we can't find what we're looking for. |
101 theme_source()->StartDataRequest("css/WRONGURL", false, 7); | 101 theme_source()->StartDataRequest("css/WRONGURL", false, 7); |
102 EXPECT_EQ(theme_source()->result_request_id_, 7); | 102 EXPECT_EQ(theme_source()->result_request_id_, 7); |
103 EXPECT_EQ(theme_source()->result_data_size_, empty_size); | 103 EXPECT_EQ(theme_source()->result_data_size_, empty_size); |
104 } | 104 } |
OLD | NEW |