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 "ash/common/system/chromeos/palette/mock_palette_tool_delegate.h" | 5 #include "ash/common/system/chromeos/palette/mock_palette_tool_delegate.h" |
6 #include "ash/common/system/chromeos/palette/palette_ids.h" | 6 #include "ash/common/system/chromeos/palette/palette_ids.h" |
7 #include "ash/common/system/chromeos/palette/palette_tool.h" | 7 #include "ash/common/system/chromeos/palette/palette_tool.h" |
8 #include "ash/common/system/chromeos/palette/tools/capture_region_action.h" | 8 #include "ash/common/system/chromeos/palette/tools/capture_region_mode.h" |
9 #include "ash/common/system/chromeos/palette/tools/capture_screen_action.h" | 9 #include "ash/common/system/chromeos/palette/tools/capture_screen_action.h" |
10 #include "ash/common/test/test_palette_delegate.h" | 10 #include "ash/common/test/test_palette_delegate.h" |
11 #include "ash/common/wm_shell.h" | 11 #include "ash/common/wm_shell.h" |
12 #include "ash/test/ash_test_base.h" | 12 #include "ash/test/ash_test_base.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/memory/ptr_util.h" | 14 #include "base/memory/ptr_util.h" |
15 | 15 |
16 namespace ash { | 16 namespace ash { |
17 | 17 |
18 namespace { | 18 namespace { |
(...skipping 21 matching lines...) Expand all Loading... |
40 protected: | 40 protected: |
41 std::unique_ptr<MockPaletteToolDelegate> palette_tool_delegate_; | 41 std::unique_ptr<MockPaletteToolDelegate> palette_tool_delegate_; |
42 | 42 |
43 private: | 43 private: |
44 DISALLOW_COPY_AND_ASSIGN(ScreenshotToolTest); | 44 DISALLOW_COPY_AND_ASSIGN(ScreenshotToolTest); |
45 }; | 45 }; |
46 | 46 |
47 } // namespace | 47 } // namespace |
48 | 48 |
49 // Verifies that capturing a region triggers the partial screenshot delegate | 49 // Verifies that capturing a region triggers the partial screenshot delegate |
50 // method, disables the tool, and hides the palette. | 50 // method. Invoking the callback passed to the delegate disables the tool. |
51 TEST_F(ScreenshotToolTest, EnablingCaptureRegionCallsDelegateAndDisablesTool) { | 51 TEST_F(ScreenshotToolTest, EnablingCaptureRegionCallsDelegateAndDisablesTool) { |
52 std::unique_ptr<PaletteTool> tool = | 52 std::unique_ptr<PaletteTool> tool = |
53 base::MakeUnique<CaptureRegionAction>(palette_tool_delegate_.get()); | 53 base::MakeUnique<CaptureRegionMode>(palette_tool_delegate_.get()); |
54 EXPECT_CALL(*palette_tool_delegate_.get(), | 54 |
55 DisableTool(PaletteToolId::CAPTURE_REGION)); | 55 // Starting a partial screenshot calls the calls the palette delegate to start |
| 56 // a screenshot session and hides the palette. |
56 EXPECT_CALL(*palette_tool_delegate_.get(), HidePalette()); | 57 EXPECT_CALL(*palette_tool_delegate_.get(), HidePalette()); |
57 tool->OnEnable(); | 58 tool->OnEnable(); |
58 EXPECT_EQ(1, test_palette_delegate()->take_partial_screenshot_count()); | 59 EXPECT_EQ(1, test_palette_delegate()->take_partial_screenshot_count()); |
| 60 testing::Mock::VerifyAndClearExpectations(palette_tool_delegate_.get()); |
| 61 |
| 62 // Calling the associated callback (partial screenshot finished) will disable |
| 63 // the tool. |
| 64 EXPECT_CALL(*palette_tool_delegate_.get(), |
| 65 DisableTool(PaletteToolId::CAPTURE_REGION)); |
| 66 test_palette_delegate()->partial_screenshot_done().Run(); |
59 } | 67 } |
60 | 68 |
61 // Verifies that capturing the screen triggers the screenshot delegate method, | 69 // Verifies that capturing the screen triggers the screenshot delegate method, |
62 // disables the tool, and hides the palette. | 70 // disables the tool, and hides the palette. |
63 TEST_F(ScreenshotToolTest, EnablingCaptureScreenCallsDelegateAndDisablesTool) { | 71 TEST_F(ScreenshotToolTest, EnablingCaptureScreenCallsDelegateAndDisablesTool) { |
64 std::unique_ptr<PaletteTool> tool = | 72 std::unique_ptr<PaletteTool> tool = |
65 base::MakeUnique<CaptureScreenAction>(palette_tool_delegate_.get()); | 73 base::MakeUnique<CaptureScreenAction>(palette_tool_delegate_.get()); |
66 EXPECT_CALL(*palette_tool_delegate_.get(), | 74 EXPECT_CALL(*palette_tool_delegate_.get(), |
67 DisableTool(PaletteToolId::CAPTURE_SCREEN)); | 75 DisableTool(PaletteToolId::CAPTURE_SCREEN)); |
68 EXPECT_CALL(*palette_tool_delegate_.get(), HidePalette()); | 76 EXPECT_CALL(*palette_tool_delegate_.get(), HidePalette()); |
69 tool->OnEnable(); | 77 tool->OnEnable(); |
70 EXPECT_EQ(1, test_palette_delegate()->take_screenshot_count()); | 78 EXPECT_EQ(1, test_palette_delegate()->take_screenshot_count()); |
71 } | 79 } |
72 | 80 |
73 } // namespace ash | 81 } // namespace ash |
OLD | NEW |