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 "chrome/browser/download/download_item_model.h" | 5 #include "chrome/browser/download/download_item_model.h" |
6 | 6 |
| 7 #include <stddef.h> |
| 8 #include <stdint.h> |
| 9 |
7 #include <vector> | 10 #include <vector> |
8 | 11 |
9 #include "base/i18n/rtl.h" | 12 #include "base/i18n/rtl.h" |
10 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/macros.h" |
11 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
12 #include "base/strings/string16.h" | 16 #include "base/strings/string16.h" |
13 #include "base/strings/string_split.h" | 17 #include "base/strings/string_split.h" |
14 #include "base/strings/string_util.h" | 18 #include "base/strings/string_util.h" |
15 #include "base/strings/utf_string_conversions.h" | 19 #include "base/strings/utf_string_conversions.h" |
16 #include "content/public/test/mock_download_item.h" | 20 #include "content/public/test/mock_download_item.h" |
17 #include "testing/gmock/include/gmock/gmock.h" | 21 #include "testing/gmock/include/gmock/gmock.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
19 #include "ui/base/resource/resource_bundle.h" | 23 #include "ui/base/resource/resource_bundle.h" |
20 #include "ui/base/text/bytes_formatting.h" | 24 #include "ui/base/text/bytes_formatting.h" |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 model().GetTooltipText(font_list, kSmallTooltipWidth); | 284 model().GetTooltipText(font_list, kSmallTooltipWidth); |
281 for (const base::string16& line : | 285 for (const base::string16& line : |
282 base::SplitString(truncated_tooltip, base::ASCIIToUTF16("\n"), | 286 base::SplitString(truncated_tooltip, base::ASCIIToUTF16("\n"), |
283 base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY)) | 287 base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY)) |
284 EXPECT_GE(kSmallTooltipWidth, gfx::GetStringWidth(line, font_list)); | 288 EXPECT_GE(kSmallTooltipWidth, gfx::GetStringWidth(line, font_list)); |
285 } | 289 } |
286 } | 290 } |
287 | 291 |
288 TEST_F(DownloadItemModelTest, InProgressStatus) { | 292 TEST_F(DownloadItemModelTest, InProgressStatus) { |
289 const struct TestCase { | 293 const struct TestCase { |
290 int64 received_bytes; // Return value of GetReceivedBytes(). | 294 int64_t received_bytes; // Return value of GetReceivedBytes(). |
291 int64 total_bytes; // Return value of GetTotalBytes(). | 295 int64_t total_bytes; // Return value of GetTotalBytes(). |
292 bool time_remaining_known; // If TimeRemaining() is known. | 296 bool time_remaining_known; // If TimeRemaining() is known. |
293 bool open_when_complete; // GetOpenWhenComplete(). | 297 bool open_when_complete; // GetOpenWhenComplete(). |
294 bool is_paused; // IsPaused(). | 298 bool is_paused; // IsPaused(). |
295 const char* expected_status; // Expected status text. | 299 const char* expected_status; // Expected status text. |
296 } kTestCases[] = { | 300 } kTestCases[] = { |
297 // These are all the valid combinations of the above fields for a download | 301 // These are all the valid combinations of the above fields for a download |
298 // that is in IN_PROGRESS state. Go through all of them and check the return | 302 // that is in IN_PROGRESS state. Go through all of them and check the return |
299 // value of DownloadItemModel::GetStatusText(). The point isn't to lock down | 303 // value of DownloadItemModel::GetStatusText(). The point isn't to lock down |
300 // the status strings, but to make sure we end up with something sane for | 304 // the status strings, but to make sure we end up with something sane for |
301 // all the circumstances we care about. | 305 // all the circumstances we care about. |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 EXPECT_CALL(item(), GetAutoOpened()) | 422 EXPECT_CALL(item(), GetAutoOpened()) |
419 .WillRepeatedly(Return(test_case.auto_opened)); | 423 .WillRepeatedly(Return(test_case.auto_opened)); |
420 | 424 |
421 EXPECT_EQ(test_case.expected_result, | 425 EXPECT_EQ(test_case.expected_result, |
422 model().ShouldRemoveFromShelfWhenComplete()) | 426 model().ShouldRemoveFromShelfWhenComplete()) |
423 << "Test case: " << i; | 427 << "Test case: " << i; |
424 Mock::VerifyAndClearExpectations(&item()); | 428 Mock::VerifyAndClearExpectations(&item()); |
425 Mock::VerifyAndClearExpectations(&model()); | 429 Mock::VerifyAndClearExpectations(&model()); |
426 } | 430 } |
427 } | 431 } |
OLD | NEW |