1"""
2Acceptance tests for L{nevow.taglibrary.tabbedPane}.
3
4Run as::
5
6    twistd -n athena-widget --element nevow.test.acceptance.tabbedpane.{tabbedPaneFragment,fetchedTabbedPaneFragment}
7"""
8
9from nevow.taglibrary.tabbedPane import TabbedPaneFragment
10from nevow import tags, athena, loaders
11
12
13def tabbedPaneFragment():
14    """
15    Return a L{TabbedPaneFragment}.  The tabbed pane should have 4 tabs: "Tab
16    0", "Tab 1", "Tab 2" and "Tab 3".  The content of each tab should be a
17    C{<h1>} node containing the tab's number.
18    """
19    return TabbedPaneFragment(
20        [('Page ' + str(i), tags.h1[str(i)]) for i in xrange(4)])
21
22
23
24class TabbedPaneFetcher(athena.LiveElement):
25    jsClass = u'Nevow.Test.TestTabbedPane.TabbedPaneFetcher'
26    docFactory = loaders.xmlstr("""
27<div xmlns:athena="http://divmod.org/ns/athena/0.7"
28  xmlns:nevow="http://nevow.com/ns/nevow/0.1"
29  nevow:render="liveElement">
30  <a href="#">
31    <athena:handler event="onclick" handler="dom_getTabbedPane" />
32    Get a tabbed pane from the server
33  </a>
34</div>""")
35
36    def getTabbedPane(self):
37        """
38        Return a L{TabbedPaneFragment}.
39        """
40        f = tabbedPaneFragment()
41        f.setFragmentParent(self)
42        return f
43    athena.expose(getTabbedPane)
44
45
46
47def fetchedTabbedPaneFragment():
48    """
49    Return a widget will fetch a L{TabbedPaneFragment} from the server when
50    asked to.  Renders as a "Get a tabbed pane from the server" link, which,
51    when clicked, will return the result of L{tabbedPaneFragment}.
52    """
53    return TabbedPaneFetcher()
54