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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: ash/common/system/chromeos/palette/tools/create_note_unittest.cc
diff --git a/ash/common/system/chromeos/palette/tools/create_note_unittest.cc b/ash/common/system/chromeos/palette/tools/create_note_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..e7c1e435dc3bb1b9f9297fd029ee7ce45ff5098a
--- /dev/null
+++ b/ash/common/system/chromeos/palette/tools/create_note_unittest.cc
@@ -0,0 +1,76 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ash/common/system/chromeos/palette/mock_palette_tool_delegate.h"
+#include "ash/common/system/chromeos/palette/palette_ids.h"
+#include "ash/common/system/chromeos/palette/palette_tool.h"
+#include "ash/common/system/chromeos/palette/tools/create_note_action.h"
+#include "ash/common/test/test_palette_delegate.h"
+#include "ash/common/wm_shell.h"
+#include "ash/test/ash_test_base.h"
+#include "base/macros.h"
+#include "base/memory/ptr_util.h"
+
+namespace ash {
+
+namespace {
+
+// Base class for all create note ash tests.
+class CreateNoteTest : public test::AshTestBase {
+ public:
+ CreateNoteTest() {}
+ ~CreateNoteTest() override {}
+
+ void SetUp() override {
+ test::AshTestBase::SetUp();
+
+ WmShell::Get()->SetPaletteDelegateForTesting(
+ base::MakeUnique<TestPaletteDelegate>());
+
+ palette_tool_delegate_ = base::MakeUnique<MockPaletteToolDelegate>();
+ tool_ = base::MakeUnique<CreateNoteAction>(palette_tool_delegate_.get());
+ }
+
+ TestPaletteDelegate* test_palette_delegate() {
+ return static_cast<TestPaletteDelegate*>(
+ WmShell::Get()->palette_delegate());
+ }
+
+ protected:
+ std::unique_ptr<MockPaletteToolDelegate> palette_tool_delegate_;
+ std::unique_ptr<PaletteTool> tool_;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(CreateNoteTest);
+};
+
+} // namespace
+
+// The note tool is only visible when there is a note-taking app available.
+TEST_F(CreateNoteTest, ViewOnlyCreatedWhenNoteAppIsAvailable) {
+ test_palette_delegate()->set_has_note_app(false);
+ EXPECT_FALSE(tool_->CreateView());
+ tool_->OnViewDestroyed();
+
+ test_palette_delegate()->set_has_note_app(true);
+ std::unique_ptr<views::View> view = base::WrapUnique(tool_->CreateView());
+ EXPECT_TRUE(view);
+ tool_->OnViewDestroyed();
+}
+
+// Activating the note tool both creates a note via the delegate and also
+// disables the tool and hides the palette.
+TEST_F(CreateNoteTest, EnablingToolCreatesNewNoteAndDisablesTool) {
+ test_palette_delegate()->set_has_note_app(true);
+ std::unique_ptr<views::View> view = base::WrapUnique(tool_->CreateView());
+
+ EXPECT_CALL(*palette_tool_delegate_.get(),
+ DisableTool(PaletteToolId::CREATE_NOTE));
+ EXPECT_CALL(*palette_tool_delegate_.get(), HidePalette());
+
+ tool_->OnEnable();
+ EXPECT_EQ(1, test_palette_delegate()->create_note_count());
+}
+
+} // namespace ash
« 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