Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(23)

Side by Side Diff: ash/common/system/chromeos/palette/tools/create_note_unittest.cc

Issue 2235063002: Add create note palette action. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@app-runtime-changes
Patch Set: Nit Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "ash/common/system/chromeos/palette/mock_palette_tool_delegate.h"
6 #include "ash/common/system/chromeos/palette/palette_ids.h"
7 #include "ash/common/system/chromeos/palette/palette_tool.h"
8 #include "ash/common/system/chromeos/palette/tools/create_note_action.h"
9 #include "ash/common/test/test_palette_delegate.h"
10 #include "ash/common/wm_shell.h"
11 #include "ash/test/ash_test_base.h"
12 #include "base/macros.h"
13 #include "base/memory/ptr_util.h"
14
15 namespace ash {
16
17 namespace {
18
19 // Base class for all create note ash tests.
20 class CreateNoteTest : public test::AshTestBase {
21 public:
22 CreateNoteTest() {}
23 ~CreateNoteTest() override {}
24
25 void SetUp() override {
26 test::AshTestBase::SetUp();
27
28 WmShell::Get()->SetPaletteDelegateForTesting(
29 base::MakeUnique<TestPaletteDelegate>());
30
31 palette_tool_delegate_ = base::MakeUnique<MockPaletteToolDelegate>();
32 tool_ = base::MakeUnique<CreateNoteAction>(palette_tool_delegate_.get());
33 }
34
35 TestPaletteDelegate* test_palette_delegate() {
36 return static_cast<TestPaletteDelegate*>(
37 WmShell::Get()->palette_delegate());
38 }
39
40 protected:
41 std::unique_ptr<MockPaletteToolDelegate> palette_tool_delegate_;
42 std::unique_ptr<PaletteTool> tool_;
43
44 private:
45 DISALLOW_COPY_AND_ASSIGN(CreateNoteTest);
46 };
47
48 } // namespace
49
50 // The note tool is only visible when there is a note-taking app available.
51 TEST_F(CreateNoteTest, ViewOnlyCreatedWhenNoteAppIsAvailable) {
52 test_palette_delegate()->set_has_note_app(false);
53 EXPECT_FALSE(tool_->CreateView());
54 tool_->OnViewDestroyed();
55
56 test_palette_delegate()->set_has_note_app(true);
57 std::unique_ptr<views::View> view = base::WrapUnique(tool_->CreateView());
58 EXPECT_TRUE(view);
59 tool_->OnViewDestroyed();
60 }
61
62 // Activating the note tool both creates a note via the delegate and also
63 // disables the tool and hides the palette.
64 TEST_F(CreateNoteTest, EnablingToolCreatesNewNoteAndDisablesTool) {
65 test_palette_delegate()->set_has_note_app(true);
66 std::unique_ptr<views::View> view = base::WrapUnique(tool_->CreateView());
67
68 EXPECT_CALL(*palette_tool_delegate_.get(),
69 DisableTool(PaletteToolId::CREATE_NOTE));
70 EXPECT_CALL(*palette_tool_delegate_.get(), HidePalette());
71
72 tool_->OnEnable();
73 EXPECT_EQ(1, test_palette_delegate()->create_note_count());
74 }
75
76 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/system/chromeos/palette/tools/create_note_action.cc ('k') | ash/common/test/test_palette_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698