diff options
author | wei <> | 2006-06-17 01:55:05 +0000 |
---|---|---|
committer | wei <> | 2006-06-17 01:55:05 +0000 |
commit | b3ceed048bb533a00bbea542f7c12b49c8c83d9b (patch) | |
tree | 97962fc3cb6746ae404c4f1d0095834bbb0e1ac7 /tests | |
parent | 6c0154fb4e292ad22667e618f598a37cc5f9d524 (diff) |
Update changes to active controls, add FT tests for active controls, add comments.
Diffstat (limited to 'tests')
27 files changed, 493 insertions, 0 deletions
diff --git a/tests/FunctionalTests/active-controls/index.php b/tests/FunctionalTests/active-controls/index.php new file mode 100644 index 00000000..8fa57a6a --- /dev/null +++ b/tests/FunctionalTests/active-controls/index.php @@ -0,0 +1,20 @@ +<?php + +$basePath=dirname(__FILE__); +$frameworkPath="/Users/weizhuo/Sites/workspace/prado-trunk/framework/prado.php"; +$assetsPath=$basePath."/assets"; +$runtimePath=$basePath."/protected/runtime"; + +if(!is_file($frameworkPath)) + die("Unable to find prado framework path $frameworkPath."); +if(!is_writable($assetsPath)) + die("Please make sure that the directory $assetsPath is writable by Web server process."); +if(!is_writable($runtimePath)) + die("Please make sure that the directory $runtimePath is writable by Web server process."); + +require_once($frameworkPath); + +$application=new TApplication; +$application->run(); + +?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/protected/.htaccess b/tests/FunctionalTests/active-controls/protected/.htaccess new file mode 100644 index 00000000..3418e55a --- /dev/null +++ b/tests/FunctionalTests/active-controls/protected/.htaccess @@ -0,0 +1 @@ +deny from all
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/protected/application.xml b/tests/FunctionalTests/active-controls/protected/application.xml new file mode 100755 index 00000000..03fe9bbb --- /dev/null +++ b/tests/FunctionalTests/active-controls/protected/application.xml @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="utf-8"?> + +<application id="FeatureTests" Mode="Debug"> + <paths> + <using namespace="System.Web.UI.ActiveControls.*" /> + </paths> + <services> + <service id="page" class="TPageService" DefaultPage="FeatureList"> + </service> + </services> +</application>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/protected/pages/ActiveButtonTest.page b/tests/FunctionalTests/active-controls/protected/pages/ActiveButtonTest.page new file mode 100644 index 00000000..5c2d1abb --- /dev/null +++ b/tests/FunctionalTests/active-controls/protected/pages/ActiveButtonTest.page @@ -0,0 +1,9 @@ +<com:TForm ID="form1"> + <h1>TActiveButton Functional Test</h1> + <com:TActiveButton ID="button2" Text="Button 1" + OnClick="button2_onclick" OnCallback="button2_oncallback" /> + + <com:TActiveLabel ID="label1" Text="Label 1" /> + + <com:TJavascriptLogger /> +</com:TForm>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/protected/pages/ActiveButtonTest.php b/tests/FunctionalTests/active-controls/protected/pages/ActiveButtonTest.php new file mode 100644 index 00000000..6282b804 --- /dev/null +++ b/tests/FunctionalTests/active-controls/protected/pages/ActiveButtonTest.php @@ -0,0 +1,16 @@ +<?php + +class ActiveButtonTest extends TPage +{ + function button2_onclick($sender, $param) + { + $this->label1->Text = "Button 1 was clicked "; + } + + function button2_oncallback($sender, $param) + { + $this->label1->Text .= "using callback!"; + } +} + +?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/protected/pages/ActivePanelTest.page b/tests/FunctionalTests/active-controls/protected/pages/ActivePanelTest.page new file mode 100644 index 00000000..468a524e --- /dev/null +++ b/tests/FunctionalTests/active-controls/protected/pages/ActivePanelTest.page @@ -0,0 +1,22 @@ +<com:TForm ID="form1"> + <h1>Active Panel replacement tests </h1> + <com:TCallback ID="callback1" OnCallback="callback1_requested" /> + <com:TActivePanel ID="panel1"> + <com:TPlaceHolder ID="content1" Visible="false"> + Something lalala <com:TButton ID="button1" Text="Button Text"/> + </com:TPlaceHolder> + </com:TActivePanel> + <div id="div1" style="border:1px solid #666; background-color: #ffe; text-align: center; padding:3em"> + Click Me! + </div> + <script type="text/javascript"> + Event.OnLoad(function() + { + Event.observe($("div1"), "click", function() + { + Prado.Callback("<%= $this->callback1->ClientID %>") + }) + }) + </script> + <com:TJavascriptLogger /> +</com:TForm>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/protected/pages/ActivePanelTest.php b/tests/FunctionalTests/active-controls/protected/pages/ActivePanelTest.php new file mode 100644 index 00000000..79e3d46c --- /dev/null +++ b/tests/FunctionalTests/active-controls/protected/pages/ActivePanelTest.php @@ -0,0 +1,12 @@ +<?php + +class ActivePanelTest extends TPage +{ + function callback1_requested($sender, $param) + { + $this->content1->visible = true; + $this->panel1->flush($param->output); + } +} + +?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/protected/pages/ActiveTextBoxCallback.page b/tests/FunctionalTests/active-controls/protected/pages/ActiveTextBoxCallback.page new file mode 100644 index 00000000..d0a750ac --- /dev/null +++ b/tests/FunctionalTests/active-controls/protected/pages/ActiveTextBoxCallback.page @@ -0,0 +1,5 @@ +<com:TForm ID="form1"> + <h1>ActiveTextBox Callback Test</h1> + <com:TActiveTextBox ID="textbox1" AutoPostBack="true" OnCallback="textbox1_callback" /> + <com:TActiveLabel ID="label1" Text="Label 1" /> +</com:TForm>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/protected/pages/ActiveTextBoxCallback.php b/tests/FunctionalTests/active-controls/protected/pages/ActiveTextBoxCallback.php new file mode 100644 index 00000000..c3f729e5 --- /dev/null +++ b/tests/FunctionalTests/active-controls/protected/pages/ActiveTextBoxCallback.php @@ -0,0 +1,11 @@ +<?php + +class ActiveTextBoxCallback extends TPage +{ + function textbox1_callback($sender, $param) + { + $this->label1->Text = 'Label 1: '.$sender->Text; + } +} + +?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/protected/pages/AutoCompleteTest.page b/tests/FunctionalTests/active-controls/protected/pages/AutoCompleteTest.page new file mode 100644 index 00000000..93658bd7 --- /dev/null +++ b/tests/FunctionalTests/active-controls/protected/pages/AutoCompleteTest.page @@ -0,0 +1,48 @@ +<com:TForm ID="form1"> + + <style> + .autocomplete + { + border:1px solid #919EA9; + background-color:white; + } + .autocomplete ul, .autocomplete li + { + margin: 0; + padding: 0; + list-style: none; + font-size: 12px; + font-family: Tahoma, Arial, Helvetica, sans-serif; + color: #333; + } + + .autocomplete li + { + padding: 4px; + border-top: 1px solid #ccc; + } + .autocomplete .selected + { + background-color: #ffc; + } + </style> + + <h1>TAutoComplete Test</h1> + + <com:TAutoComplete Style="width: 20em" + OnCallback="suggestCountries" + Separator=", " + ResultPanel.CssClass="autocomplete" /> + + <p><br /></p> + <p><br /></p> + <p><br /></p> + <p><br /></p> + <p><br /></p> + <p><br /></p> + <p><br /></p> + <p><br /></p> + <p><br /></p> + <p><br /></p> + <com:TJavascriptLogger /> +</com:TForm>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/protected/pages/AutoCompleteTest.php b/tests/FunctionalTests/active-controls/protected/pages/AutoCompleteTest.php new file mode 100644 index 00000000..938b8640 --- /dev/null +++ b/tests/FunctionalTests/active-controls/protected/pages/AutoCompleteTest.php @@ -0,0 +1,34 @@ +<?php +/* + * Created on 7/05/2006 + */ + +class AutoCompleteTest extends TPage +{ + public function suggestCountries($sender, $param) + { + $sender->setDataSource($this->matchCountries($param->getParameter())); + $sender->dataBind(); + $sender->render($param->getOutput()); + } + + protected function matchCountries($token) + { + $info = Prado::createComponent('System.I18N.core.CultureInfo', 'en'); + $list = array(); + $count = 0; + $token = strtolower($token); + foreach($info->getCountries() as $country) + { + if(strpos(strtolower($country), $token) === 0) + { + $list[] = $country; + $count++; + if($count > 10) break; + } + } + return $list; + } +} + +?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/protected/pages/Calculator.page b/tests/FunctionalTests/active-controls/protected/pages/Calculator.page new file mode 100644 index 00000000..7a565658 --- /dev/null +++ b/tests/FunctionalTests/active-controls/protected/pages/Calculator.page @@ -0,0 +1,31 @@ +<com:TForm ID="form1"> + <h1>Callback Enabled Calculator</h1> + + <com:TActiveTextBox id="a" /> + + + <com:TActiveTextBox id="b" /> + = + <com:TActiveTextBox id="c" /> + + <com:TActiveButton id="sum" + onclick="do_sum" + text="Calculate!" /> + + <com:TRequiredFieldValidator + ControlToValidate="a" + ErrorMessage="left summand is required." + ControlCssClass="required" + Display="None" /> + <com:TRequiredFieldValidator + ControlToValidate="b" + ErrorMessage="right summand is requied." + ControlCssClass="required" + Display="None" /> + + <div class="summarybox"> + <com:TValidationSummary + ID="summary" + HeaderText="Unable to calculate because" /> + </div> + +</com:TForm>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/protected/pages/Calculator.php b/tests/FunctionalTests/active-controls/protected/pages/Calculator.php new file mode 100644 index 00000000..098a8460 --- /dev/null +++ b/tests/FunctionalTests/active-controls/protected/pages/Calculator.php @@ -0,0 +1,12 @@ +<?php + +class Calculator extends TPage +{ + public function do_sum($sender, $param) + { + $this->c->Text = floatval($this->a->Text) + floatval($this->b->Text); + } +} + + +?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/protected/pages/CallbackOptionsTest.page b/tests/FunctionalTests/active-controls/protected/pages/CallbackOptionsTest.page new file mode 100644 index 00000000..6e8b8a1e --- /dev/null +++ b/tests/FunctionalTests/active-controls/protected/pages/CallbackOptionsTest.page @@ -0,0 +1,34 @@ +<com:TForm ID="form1"> + <h1>TCallbackOptions Test</h1> + + <com:TCallbackOptions ID="options1"> + <prop:ClientSide.OnLoading> + $("status").show(); + </prop:ClientSide.OnLoading> + <prop:ClientSide.OnComplete> + $("status").hide(); + </prop:ClientSide.OnComplete> + <prop:ClientSide.OnSuccess> + Element.update("label1", "Button 1 has returned"); + </prop:ClientSide.OnSuccess> + </com:TCallbackOptions> + + <com:TActiveButton id="button1" Text="Button 1" ActiveControl.CallbackOptions="options1" /> + <com:TActiveButton id="button2" Text="Button 2" ActiveControl.CallbackOptions="options1"> + <prop:ActiveControl.ClientSide.OnSuccess> + Element.update("label2", "Button 2 has returned"); + </prop:ActiveControl.ClientSide.OnSuccess> + </com:TActiveButton> + <com:TActiveButton id="button3" Text="Button 3"> + <prop:ActiveControl.ClientSide.OnSuccess> + Element.update("label3", "Button 3 has returned"); + </prop:ActiveControl.ClientSide.OnSuccess> + </com:TActiveButton> + + <div id="label1">Label 1</div> + <div id="label2">Label 2</div> + <div id="label3">Label 3</div> + <div id="status" style="display:none; background-color: #c00; color:white; text-align:center; padding: 1em" > + Loading... + </div> +</com:TForm>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/protected/pages/FeatureList.page b/tests/FunctionalTests/active-controls/protected/pages/FeatureList.page new file mode 100755 index 00000000..eab14a87 --- /dev/null +++ b/tests/FunctionalTests/active-controls/protected/pages/FeatureList.page @@ -0,0 +1,3 @@ +<com:TForm ID="form1"> + <com:TBulletedList ID="List" DisplayMode="HyperLink"/> +</com:TForm> diff --git a/tests/FunctionalTests/active-controls/protected/pages/FeatureList.php b/tests/FunctionalTests/active-controls/protected/pages/FeatureList.php new file mode 100755 index 00000000..8f28f6de --- /dev/null +++ b/tests/FunctionalTests/active-controls/protected/pages/FeatureList.php @@ -0,0 +1,34 @@ +<?php + +class FeatureList extends TPage +{ + public function onLoad($param) + { + parent::onLoad($param); + $list=$this->getPageList(dirname(__FILE__),''); + $this->List->DataSource=$list; + $this->List->dataBind(); + } + + protected function getPageList($directory,$basePath) + { + $list=array(); + $folder=@opendir($directory); + while($entry=@readdir($folder)) + { + if($entry[0]==='.') + continue; + else if(is_file($directory.'/'.$entry)) + { + if(($page=basename($entry,'.page'))!==$entry && strpos($page,'.')===false) + $list['?page='.$basePath.$page]=$basePath.$page; + } + else + $list=array_merge($list,$this->getPageList($directory.'/'.$entry,$basePath.$entry.'.')); + } + closedir($folder); + return $list; + } +} + +?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/protected/pages/Home.page b/tests/FunctionalTests/active-controls/protected/pages/Home.page new file mode 100644 index 00000000..ff226d4e --- /dev/null +++ b/tests/FunctionalTests/active-controls/protected/pages/Home.page @@ -0,0 +1 @@ +<h1>Welcome to Prado!</h1>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/protected/pages/NestedActiveControls.page b/tests/FunctionalTests/active-controls/protected/pages/NestedActiveControls.page new file mode 100644 index 00000000..d8eacf15 --- /dev/null +++ b/tests/FunctionalTests/active-controls/protected/pages/NestedActiveControls.page @@ -0,0 +1,28 @@ +<com:TForm ID="form1"> + <h1>Nested Active Controls Test</h1> + <com:TCallback ID="callback1" OnCallback="callback1_requested" /> + <com:TActivePanel ID="panel1"> + <com:TPlaceHolder ID="content1" Visible="false"> + Something lalala + <com:TActiveButton ID="button1" Text="Button 1" OnClick="button1_clicked" /> + <com:TActiveLabel ID="label3" Text="Label 3" /> + + </com:TPlaceHolder> + <com:TActiveLabel ID="label1" Text="Label 1" /> + </com:TActivePanel> + <div id="div1" style="border:1px solid #666; background-color: #ffe; text-align: center; padding:1em; margin: 2em"> + Click Me! + </div> + <com:TActiveLabel ID="label2" Text="Label 2" /> + <script type="text/javascript"> + Event.OnLoad(function() + { + Event.observe($("div1"), "click", function() + { + Prado.Callback("<%= $this->callback1->ClientID %>") + }) + }) + </script> + <com:TJavascriptLogger /> + +</com:TForm> diff --git a/tests/FunctionalTests/active-controls/protected/pages/NestedActiveControls.php b/tests/FunctionalTests/active-controls/protected/pages/NestedActiveControls.php new file mode 100644 index 00000000..a4a22cbf --- /dev/null +++ b/tests/FunctionalTests/active-controls/protected/pages/NestedActiveControls.php @@ -0,0 +1,19 @@ +<?php + +class NestedActiveControls extends TPage +{ + function callback1_requested($sender, $param) + { + $this->content1->visible = true; + $this->panel1->flush($param->output); + } + + function button1_clicked($sender, $param) + { + $this->label1->Text = "Label 1: Button 1 Clicked"; + $this->label2->Text = "Label 2: Button 1 Clicked"; + $this->label3->Text = "Label 3: Button 1 Clicked"; + } +} + +?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/tests/ActiveButtonTestCase.php b/tests/FunctionalTests/active-controls/tests/ActiveButtonTestCase.php new file mode 100644 index 00000000..0a294906 --- /dev/null +++ b/tests/FunctionalTests/active-controls/tests/ActiveButtonTestCase.php @@ -0,0 +1,16 @@ +<?php + +class ActiveButtonTestCase extends SeleniumTestCase +{ + function test() + { + $this->open("active-controls/index.php?page=ActiveButtonTest"); + $this->verifyTextPresent("TActiveButton Functional Test"); + $this->assertText("label1", "Label 1"); + $this->click("button2"); + $this->pause(500); + $this->assertText("label1", "Button 1 was clicked using callback!"); + } +} + +?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/tests/ActivePanelTestCase.php b/tests/FunctionalTests/active-controls/tests/ActivePanelTestCase.php new file mode 100644 index 00000000..a9fb6c4e --- /dev/null +++ b/tests/FunctionalTests/active-controls/tests/ActivePanelTestCase.php @@ -0,0 +1,16 @@ +<?php + +class ActivePanelTestCase extends SeleniumTestCase +{ + function test() + { + $this->open("active-controls/index.php?page=ActivePanelTest"); + $this->verifyTextPresent("Active Panel replacement tests"); + $this->assertTextNotPresent('Something lalala'); + $this->click("div1"); + $this->pause(500); + $this->assertTextPresent("Something lalala"); + } +} + +?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/tests/CalculatorTestCase.php b/tests/FunctionalTests/active-controls/tests/CalculatorTestCase.php new file mode 100644 index 00000000..2fb28224 --- /dev/null +++ b/tests/FunctionalTests/active-controls/tests/CalculatorTestCase.php @@ -0,0 +1,24 @@ +<?php + +class CalculatorTestCase extends SeleniumTestCase +{ + function test() + { + $this->open("active-controls/index.php?page=Calculator"); + $this->assertTextPresent("Callback Enabled Calculator"); + $this->assertNotVisible("summary"); + + $this->click("sum"); + $this->assertVisible("summary"); + + $this->type("a", "2"); + $this->type("b", "5"); + + $this->click("sum"); + $this->assertNotVisible("summary"); + + $this->assertValue("c", "7"); + } +} + +?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/tests/CallbackOptionsTestCase.php b/tests/FunctionalTests/active-controls/tests/CallbackOptionsTestCase.php new file mode 100644 index 00000000..d72499cf --- /dev/null +++ b/tests/FunctionalTests/active-controls/tests/CallbackOptionsTestCase.php @@ -0,0 +1,34 @@ +<?php + +class CallbackOptionsTestCase extends SeleniumTestCase +{ + function test() + { + $this->open("active-controls/index.php?page=CallbackOptionsTest"); + $this->verifyTextPresent("TCallbackOptions Test"); + + $this->assertText("label1", "Label 1"); + $this->assertText("label2", "Label 2"); + $this->assertText("label3", "Label 3"); + + $this->click("button1"); + $this->pause(500); + $this->assertText("label1", "Button 1 has returned"); + $this->assertText("label2", "Label 2"); + $this->assertText("label3", "Label 3"); + + $this->click("button2"); + $this->pause(500); + $this->assertText("label1", "Button 1 has returned"); + $this->assertText("label2", "Button 2 has returned"); + $this->assertText("label3", "Label 3"); + + $this->click("button3"); + $this->pause(500); + $this->assertText("label1", "Button 1 has returned"); + $this->assertText("label2", "Button 2 has returned"); + $this->assertText("label3", "Button 3 has returned"); + } +} + +?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/tests/NestedActiveControlsTestCase.php b/tests/FunctionalTests/active-controls/tests/NestedActiveControlsTestCase.php new file mode 100644 index 00000000..8d0cfb87 --- /dev/null +++ b/tests/FunctionalTests/active-controls/tests/NestedActiveControlsTestCase.php @@ -0,0 +1,26 @@ +<?php + +class NestedActiveControlsTestCase extends SeleniumTestCase +{ + function test() + { + $this->open("active-controls/index.php?page=NestedActiveControls"); + $this->verifyTextPresent("Nested Active Controls Test"); + $this->assertText("label1", "Label 1"); + $this->assertText("label2", "Label 2"); + $this->assertTextNotPresent("Label 3"); + + $this->click("div1"); + $this->pause(500); + $this->assertTextPresent("Something lalala"); + $this->assertText("label3", "Label 3"); + + $this->click("button1"); + $this->pause(500); + $this->assertText("label1", "Label 1: Button 1 Clicked"); + $this->assertText("label2", "Label 2: Button 1 Clicked"); + $this->assertText("label3", "Label 3: Button 1 Clicked"); + } +} + +?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/tests/TextBoxCallbackTestCase.php b/tests/FunctionalTests/active-controls/tests/TextBoxCallbackTestCase.php new file mode 100644 index 00000000..24cba49b --- /dev/null +++ b/tests/FunctionalTests/active-controls/tests/TextBoxCallbackTestCase.php @@ -0,0 +1,17 @@ +<?php + +class TextBoxCallbackTestCase extends SeleniumTestCase +{ + function test() + { + $this->open("active-controls/index.php?page=ActiveTextBoxCallback"); + $this->verifyTextPresent("ActiveTextBox Callback Test"); + $this->assertText("label1", "Label 1"); + + $this->type("textbox1", "hello!"); + $this->pause(500); + $this->assertText("label1", "Label 1: hello!"); + } +} + +?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active.php b/tests/FunctionalTests/active.php new file mode 100755 index 00000000..ca6ab635 --- /dev/null +++ b/tests/FunctionalTests/active.php @@ -0,0 +1,8 @@ +<?php + +require(dirname(__FILE__).'/PradoTester.php'); + +$tester=new PradoTester(dirname(__FILE__).'/active-controls/tests'); +$tester->run(new SimpleReporter()); + +?>
\ No newline at end of file diff --git a/tests/FunctionalTests/index.php b/tests/FunctionalTests/index.php index c22543c0..ceba599a 100644 --- a/tests/FunctionalTests/index.php +++ b/tests/FunctionalTests/index.php @@ -9,6 +9,7 @@ Prado Functional Test Suites <ul> <li><a href="quickstart.php">Tests of QuickStart Tutorial Demo</a></li> <li><a href="validators.php">Tests of Validators</a></li> + <li><a href="active.php">Tests of Active Controls</a> (<a href="active-controls/index.php">list of test samples</a>) </li> <li><a href="tickets.php">Tests of Trac Tickets</a></li> <li><a href="features.php">Tests of New Features</a> (<a href="features/index.php">list of new features</a>)</li> </ul> |