OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/media/webrtc/tab_desktop_media_list.h" | 5 #include "chrome/browser/media/webrtc/tab_desktop_media_list.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 } | 55 } |
56 return new TestingProfile(file_path, NULL); | 56 return new TestingProfile(file_path, NULL); |
57 } | 57 } |
58 }; | 58 }; |
59 | 59 |
60 // Create a greyscale image with certain size and grayscale value. | 60 // Create a greyscale image with certain size and grayscale value. |
61 gfx::Image CreateGrayscaleImage(gfx::Size size, uint8_t greyscale_value) { | 61 gfx::Image CreateGrayscaleImage(gfx::Size size, uint8_t greyscale_value) { |
62 SkBitmap result; | 62 SkBitmap result; |
63 result.allocN32Pixels(size.width(), size.height(), true); | 63 result.allocN32Pixels(size.width(), size.height(), true); |
64 | 64 |
65 result.lockPixels(); | |
66 uint8_t* pixels_data = reinterpret_cast<uint8_t*>(result.getPixels()); | 65 uint8_t* pixels_data = reinterpret_cast<uint8_t*>(result.getPixels()); |
67 | 66 |
68 // Set greyscale value for all pixels. | 67 // Set greyscale value for all pixels. |
69 for (int y = 0; y < result.height(); ++y) { | 68 for (int y = 0; y < result.height(); ++y) { |
70 for (int x = 0; x < result.width(); ++x) { | 69 for (int x = 0; x < result.width(); ++x) { |
71 pixels_data[result.rowBytes() * y + x * result.bytesPerPixel()] = | 70 pixels_data[result.rowBytes() * y + x * result.bytesPerPixel()] = |
72 greyscale_value; | 71 greyscale_value; |
73 pixels_data[result.rowBytes() * y + x * result.bytesPerPixel() + 1] = | 72 pixels_data[result.rowBytes() * y + x * result.bytesPerPixel() + 1] = |
74 greyscale_value; | 73 greyscale_value; |
75 pixels_data[result.rowBytes() * y + x * result.bytesPerPixel() + 2] = | 74 pixels_data[result.rowBytes() * y + x * result.bytesPerPixel() + 2] = |
76 greyscale_value; | 75 greyscale_value; |
77 pixels_data[result.rowBytes() * y + x * result.bytesPerPixel() + 3] = | 76 pixels_data[result.rowBytes() * y + x * result.bytesPerPixel() + 3] = |
78 0xff; | 77 0xff; |
79 } | 78 } |
80 } | 79 } |
81 | 80 |
82 result.unlockPixels(); | |
83 | |
84 return gfx::Image::CreateFrom1xBitmap(result); | 81 return gfx::Image::CreateFrom1xBitmap(result); |
85 } | 82 } |
86 | 83 |
87 } // namespace | 84 } // namespace |
88 | 85 |
89 class MockObserver : public DesktopMediaListObserver { | 86 class MockObserver : public DesktopMediaListObserver { |
90 public: | 87 public: |
91 MOCK_METHOD2(OnSourceAdded, void(DesktopMediaList* list, int index)); | 88 MOCK_METHOD2(OnSourceAdded, void(DesktopMediaList* list, int index)); |
92 MOCK_METHOD2(OnSourceRemoved, void(DesktopMediaList* list, int index)); | 89 MOCK_METHOD2(OnSourceRemoved, void(DesktopMediaList* list, int index)); |
93 MOCK_METHOD3(OnSourceMoved, | 90 MOCK_METHOD3(OnSourceMoved, |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 favicon_info.image = CreateGrayscaleImage(gfx::Size(10, 10), 100); | 350 favicon_info.image = CreateGrayscaleImage(gfx::Size(10, 10), 100); |
354 contents->GetController().GetTransientEntry()->GetFavicon() = favicon_info; | 351 contents->GetController().GetTransientEntry()->GetFavicon() = favicon_info; |
355 | 352 |
356 EXPECT_CALL(observer_, OnSourceThumbnailChanged(list_.get(), 0)) | 353 EXPECT_CALL(observer_, OnSourceThumbnailChanged(list_.get(), 0)) |
357 .WillOnce(QuitMessageLoop()); | 354 .WillOnce(QuitMessageLoop()); |
358 | 355 |
359 base::RunLoop().Run(); | 356 base::RunLoop().Run(); |
360 | 357 |
361 list_.reset(); | 358 list_.reset(); |
362 } | 359 } |
OLD | NEW |