-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
157 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# encoding: utf-8 | ||
|
||
# ------------------------------------------------------------------------------ | ||
# Copyright (c) 2018 SUSE LLC | ||
# | ||
# | ||
# This program is free software; you can redistribute it and/or modify it under | ||
# the terms of version 2 of the GNU General Public License as published by the | ||
# Free Software Foundation. | ||
# | ||
# This program is distributed in the hope that it will be useful, but WITHOUT | ||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License along with | ||
# this program; if not, contact SUSE. | ||
# | ||
# To contact SUSE about this file by physical or electronic mail, you may find | ||
# current contact information at www.suse.com. | ||
# ------------------------------------------------------------------------------ | ||
|
||
require "yast" | ||
require "cwm/tree" | ||
|
||
module Y2Firewall | ||
module Widgets | ||
# A tree that is told what its items are. | ||
# We need a tree whose items include Pages that point to the OverviewTreePager. | ||
class OverviewTree < CWM::Tree | ||
# @!attribute [r] items | ||
# @return [Array<CWM::PagerTreeItem>] List of tree items | ||
attr_reader :items | ||
|
||
# Constructor | ||
# | ||
# @param items [Array<CWM::PagerTreeItem>] List of tree items to be included | ||
def initialize(items) | ||
textdomain "firewall" | ||
@items = items | ||
end | ||
|
||
# @macro seeAbstractWidget | ||
def label | ||
_("System View") | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#!/usr/bin/env rspec | ||
# encoding: utf-8 | ||
|
||
# Copyright (c) [2018] SUSE LLC | ||
# | ||
# All Rights Reserved. | ||
# | ||
# This program is free software; you can redistribute it and/or modify it | ||
# under the terms of version 2 of the GNU General Public License as published | ||
# by the Free Software Foundation. | ||
# | ||
# This program is distributed in the hope that it will be useful, but WITHOUT | ||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
# more details. | ||
# | ||
# You should have received a copy of the GNU General Public License along | ||
# with this program; if not, contact SUSE LLC. | ||
# | ||
# To contact SUSE LLC about this file by physical or electronic mail, you may | ||
# find current contact information at www.suse.com. | ||
|
||
require_relative "../../../test_helper.rb" | ||
require "cwm/rspec" | ||
require "y2firewall/widgets/overview_tree_pager" | ||
require "y2firewall/widgets/pages" | ||
|
||
describe Y2Firewall::Widgets::OverviewTreePager do | ||
subject(:widget) { described_class.new } | ||
|
||
let(:startup_page) { double("Startup").as_null_object } | ||
|
||
before do | ||
allow(Y2Firewall::Widgets::Pages::Startup).to receive(:new) | ||
.and_return(startup_page) | ||
end | ||
|
||
describe "#initial_page" do | ||
it "navigates to the page stored in the UIState instance" do | ||
expect(Y2Firewall::UIState.instance).to receive(:find_tree_node) | ||
widget.initial_page | ||
end | ||
end | ||
|
||
describe "#switch_page" do | ||
let(:page) { Y2Firewall::Widgets::Pages::Zones.new(double("pager")) } | ||
|
||
it "registers the page in the UIState instance" do | ||
expect(Y2Firewall::UIState.instance).to receive(:go_to_tree_node).with(page) | ||
widget.switch_page(page) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/usr/bin/env rspec | ||
# encoding: utf-8 | ||
|
||
# Copyright (c) [2018] SUSE LLC | ||
# | ||
# All Rights Reserved. | ||
# | ||
# This program is free software; you can redistribute it and/or modify it | ||
# under the terms of version 2 of the GNU General Public License as published | ||
# by the Free Software Foundation. | ||
# | ||
# This program is distributed in the hope that it will be useful, but WITHOUT | ||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
# more details. | ||
# | ||
# You should have received a copy of the GNU General Public License along | ||
# with this program; if not, contact SUSE LLC. | ||
# | ||
# To contact SUSE LLC about this file by physical or electronic mail, you may | ||
# find current contact information at www.suse.com. | ||
|
||
require_relative "../../../test_helper.rb" | ||
require "cwm/rspec" | ||
require "y2firewall/widgets/overview_tree" | ||
require "cwm/tree_pager" | ||
|
||
describe Y2Firewall::Widgets::OverviewTree do | ||
subject(:widget) { described_class.new([tree_item1, tree_item2]) } | ||
|
||
let(:tree_item1) { instance_double(CWM::PagerTreeItem) } | ||
let(:tree_item2) { instance_double(CWM::PagerTreeItem) } | ||
|
||
describe "#items" do | ||
it "returns the list of included items" do | ||
expect(widget.items).to eq([tree_item1, tree_item2]) | ||
end | ||
end | ||
end |