Index: devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/pages/common/HomePage.java
===================================================================
--- devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/pages/common/HomePage.java	(revision 4917)
+++ devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/pages/common/HomePage.java	(revision 5025)
@@ -28,5 +28,5 @@
 	 */
 	public void enterMail() {
-		mail.click();
+		super.findAndClickElement(By.xpath("//a/img[@id='expressoMail12id']"));
 		waitForElement(By
 				.xpath("//table[@id='folders_tbl']/tbody/tr[1]/td/table/tbody/tr[2]/td/div/span"));
Index: devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/pages/common/Page.java
===================================================================
--- devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/pages/common/Page.java	(revision 4962)
+++ devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/pages/common/Page.java	(revision 5025)
@@ -53,5 +53,5 @@
 	 */
 	public void waitForElement(By by) {
-		isDisplayed(this.waitFindElement(by, 10000, 1000));
+		isDisplayed(this.waitFindElement(by, 100000, 1000));
 	}
 
@@ -200,4 +200,65 @@
 	}
 
+	public List<WebElement> getComboElements(WebElement element) {
+		return element.findElements(By.tagName("option"));
+	}
+
+	/**
+	 * Seleciona todos os valores de um combo.
+	 * 
+	 * @param element
+	 */
+	public void selectAllComboValue(WebElement element) {
+		List<WebElement> options = element.findElements(By.tagName("option"));
+		for (WebElement option : options) {
+			option.setSelected();
+		}
+	}
+
+	/**
+	 * Verifica se o valor passado esta presente na combo box.
+	 * 
+	 * @param element
+	 *            Elemento a verificar.
+	 * @param value
+	 *            Valor a verificar.
+	 * @param select
+	 *            Se <code>true</code> seleciona o elemento.
+	 * @return
+	 */
+	public boolean isValueInCombo(WebElement element, String value,
+			Boolean select) {
+
+		boolean found = false;
+		try {
+			List<WebElement> options = element.findElements(By
+					.tagName("option"));
+			for (WebElement option : options) {
+				if (option.getText().equals(value)) {
+					found = true;
+					if (select) {
+						option.setSelected();
+					}
+
+				}
+			}
+		} catch (NoSuchElementException nsee) {
+			System.out.println("Warning: ELEMENTO NAO ENCONTRADO!");
+			found = false;
+		}
+
+		// TODO Rever o tratamento da excecao quando um valor nao for encontrado
+		// na combobox.
+
+		try {
+			throw new Exception("Valor " + value + " nÃ£o encontrado em "
+					+ element);
+		} catch (Exception e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		return found;
+	}
+
 	/**
 	 * Verifica se um element esta presente na tela.
Index: devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/pages/calendar/AppointmentStatusPage.java
===================================================================
--- devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/pages/calendar/AppointmentStatusPage.java	(revision 4962)
+++ devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/pages/calendar/AppointmentStatusPage.java	(revision 5025)
@@ -4,4 +4,5 @@
 
 import org.expressolivre.cte.pages.common.Page;
+import org.openqa.selenium.By;
 import org.openqa.selenium.WebDriver;
 import org.openqa.selenium.WebElement;
@@ -34,4 +35,6 @@
 
 	public String getMessage() {
+		super.waitForElement(By
+				.xpath("/html/body/center[1]/table/tbody/tr[1]/td/b/font"));
 		return this.message.getText();
 	}
@@ -49,5 +52,5 @@
 
 		// wait for the new window to close
-		new WebDriverWait(driver, 30) {
+		new WebDriverWait(driver, 100) {
 		}.until(new ExpectedCondition<Boolean>() {
 			public Boolean apply(WebDriver driver) {
@@ -61,4 +64,5 @@
 		String newWindowHandle = afterHandles.iterator().next();
 		driver.switchTo().window(newWindowHandle);
+		driver.switchTo().defaultContent();
 
 		return PageFactory.initElements(driver, AppointmentEmailPage.class);
Index: devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/pages/calendar/AppointmentEmailPage.java
===================================================================
--- devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/pages/calendar/AppointmentEmailPage.java	(revision 4962)
+++ devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/pages/calendar/AppointmentEmailPage.java	(revision 5025)
@@ -42,5 +42,5 @@
 
 		// wait for the new window to open
-		new WebDriverWait(driver, 30) {
+		new WebDriverWait(driver, 100) {
 		}.until(new ExpectedCondition<Boolean>() {
 			public Boolean apply(WebDriver driver) {
@@ -58,4 +58,5 @@
 		String newWindowHandle = afterHandles.iterator().next();
 		driver.switchTo().window(newWindowHandle);
+		driver.switchTo().defaultContent();
 
 		return PageFactory.initElements(driver, AppointmentStatusPage.class);
@@ -73,5 +74,5 @@
 
 		// wait for the new window to open
-		new WebDriverWait(driver, 30) {
+		new WebDriverWait(driver, 100) {
 		}.until(new ExpectedCondition<Boolean>() {
 			public Boolean apply(WebDriver driver) {
@@ -89,4 +90,5 @@
 		String newWindowHandle = afterHandles.iterator().next();
 		driver.switchTo().window(newWindowHandle);
+		driver.switchTo().defaultContent();
 
 		return PageFactory.initElements(driver, AppointmentStatusPage.class);
@@ -104,5 +106,5 @@
 
 		// wait for the new window to open
-		new WebDriverWait(driver, 30) {
+		new WebDriverWait(driver, 100) {
 		}.until(new ExpectedCondition<Boolean>() {
 			public Boolean apply(WebDriver driver) {
@@ -120,4 +122,5 @@
 		String newWindowHandle = afterHandles.iterator().next();
 		driver.switchTo().window(newWindowHandle);
+		driver.switchTo().defaultContent();
 
 		return PageFactory.initElements(driver, AppointmentStatusPage.class);
Index: devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/pages/calendar/CalendarPage.java
===================================================================
--- devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/pages/calendar/CalendarPage.java	(revision 4962)
+++ devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/pages/calendar/CalendarPage.java	(revision 5025)
@@ -174,4 +174,14 @@
 
 	/**
+	 * Seleciona um usuario listar seus compromissos.
+	 * 
+	 * @param user
+	 *            Usuario selecionado.
+	 */
+	public void setOwner(String user) {
+		super.setComboValue(this.owner, user);
+	}
+
+	/**
 	 * Seleciona um mes para filtragem.
 	 * 
Index: devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/pages/calendar/AgendaPermissionPage.java
===================================================================
--- devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/pages/calendar/AgendaPermissionPage.java	(revision 4962)
+++ devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/pages/calendar/AgendaPermissionPage.java	(revision 5025)
@@ -1,4 +1,5 @@
 package org.expressolivre.cte.pages.calendar;
 
+import java.util.List;
 import java.util.Set;
 
@@ -60,4 +61,25 @@
 
 	/**
+	 * Verifica se o usuario ja esta na lista de permissoes.
+	 * 
+	 * @param userName
+	 * @return
+	 */
+	public Boolean isUserInList(String userName) {
+		return super.isValueInCombo(this.userList, userName, true);
+	}
+
+	/**
+	 * Remove todos os usuarios do compartilhamento.
+	 */
+	public void removeAllUsers() {
+		List<WebElement> users = super.getComboElements(this.userList);
+		for (WebElement user : users) {
+			user.setSelected();
+			this.removeButton.click();
+		}
+	}
+
+	/**
 	 * Adaptacao da solucao para lidar com janelas popups obtida em <a
 	 * href="http://groups.google.com/group
@@ -92,6 +114,50 @@
 	}
 
-	public void setReadPermission() {
-		this.read.click();
+	public void setReadPermission(boolean read) {
+		if (read && !this.read.isSelected()) {
+			this.read.click();
+		} else if (!read && this.read.isSelected()) {
+			this.read.click();
+		}
+	}
+
+	public void setEditPermission(boolean edit) {
+		if (edit && !this.edit.isSelected()) {
+			this.edit.click();
+		} else if (!edit && this.edit.isSelected()) {
+			this.edit.click();
+		}
+	}
+
+	public void setAddPermission(boolean add) {
+		if (add && !this.add.isSelected()) {
+			this.add.click();
+		} else if (!add && this.add.isSelected()) {
+			this.add.click();
+		}
+	}
+
+	public void setRemovePermission(boolean remove) {
+		if (remove && !this.remove.isSelected()) {
+			this.remove.click();
+		} else if (!remove && this.remove.isSelected()) {
+			this.remove.click();
+		}
+	}
+
+	public void setRestrictPermission(boolean restrict) {
+		if (restrict && !this.restrict.isSelected()) {
+			this.restrict.click();
+		} else if (!restrict && this.restrict.isSelected()) {
+			this.restrict.click();
+		}
+	}
+
+	public void clearPemissions() {
+		this.setReadPermission(false);
+		this.setEditPermission(false);
+		this.setRemovePermission(false);
+		this.setAddPermission(false);
+		this.setRestrictPermission(false);
 	}
 
@@ -99,3 +165,7 @@
 		this.cancelButton.click();
 	}
+
+	public void apply() {
+		this.okButton.click();
+	}
 }
Index: devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/pages/calendar/AppointmentViewPage.java
===================================================================
--- devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/pages/calendar/AppointmentViewPage.java	(revision 4962)
+++ devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/pages/calendar/AppointmentViewPage.java	(revision 5025)
@@ -22,5 +22,5 @@
 	public static final String DESCRIPTION = "DescriÃ§Ã£o:";
 	public static final String LOCAL = "LocalizaÃ§Ã£o:";
-	public static final String START = "InÃ­cio Data/Hora:";
+	public static final String START = "InÃ­cio Data/hora:";
 	public static final String END = "Data/Hora de tÃ©rmino:";
 	public static final String PRIORITY = "Prioridade:";
@@ -39,4 +39,7 @@
 	@FindBy(xpath = "//table[@id='calendar_viewevent_button_left']/tbody/tr/td[2]/nobr/form/div/input[@id='']")
 	private WebElement editSeriesButton;
+
+	@FindBy(xpath = "//table[@id='calendar_viewevent_button_left']/tbody/tr/td[2]/nobr/form/div/input[@id='']")
+	private WebElement readyButton;
 
 	@FindBy(xpath = "//table[@id='calendar_viewevent_button_right']/tbody/tr/td/nobr/form/div/input[@id='']")
@@ -82,4 +85,11 @@
 		this.removeButton.click();
 		this.removeAlert();
+	}
+
+	/**
+	 * 
+	 */
+	public void ready() {
+		this.readyButton.click();
 	}
 
Index: devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/email/compor/SalvarEmailSomenteCopiaTestCase.java
===================================================================
--- devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/email/compor/SalvarEmailSomenteCopiaTestCase.java	(revision 4606)
+++ devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/email/compor/SalvarEmailSomenteCopiaTestCase.java	(revision 5025)
@@ -45,11 +45,12 @@
 		// Retirar o <span></span> que Ã© colocado no momento de visualizar o
 		// email para edicao.
-		int spanOpen = body.indexOf("<span>") + 7;
-		int spanClose = body.lastIndexOf("</span>") - 1;
+		int spanOpen = body.indexOf("<span><span>") + 13;
+		int spanClose = body.lastIndexOf("</span></span>") - 1;
 		body = body.substring(spanOpen, spanClose).trim();
+
+		mp.closeMail(id, true);
 
 		Assert.assertEquals(EMAIL_TEXTO_SALVAR_SOMENTE_COPIA, body);
 
-		mp.closeMail(id, true);
 	}
 
Index: devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/email/compor/SalvarEmailSomenteCopiaOcultaTestCase.java
===================================================================
--- devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/email/compor/SalvarEmailSomenteCopiaOcultaTestCase.java	(revision 4606)
+++ devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/email/compor/SalvarEmailSomenteCopiaOcultaTestCase.java	(revision 5025)
@@ -44,12 +44,16 @@
 		Assert.assertEquals(EMAIL_TESTE_1, mp.getBlindCarbonCopy(id).getValue());
 		String body = mp.getBody(id).toString();
+
 		// Retirar o <span></span> que Ã© colocado no momento de visualizar o
 		// email para edicao.
-		int spanOpen = body.indexOf("<span>") + 7;
-		int spanClose = body.lastIndexOf("</span>") - 1;
+		int spanOpen = body.indexOf("<span><span>") + 13;
+		int spanClose = body.lastIndexOf("</span></span>") - 1;
 		body = body.substring(spanOpen, spanClose).trim();
-		Assert.assertEquals(EMAIL_TEXTO_SALVAR_SOMENTE_COPIA_OCULTA, body);
+
+		System.out.println(body);
 
 		mp.closeMail(id, true);
+
+		Assert.assertEquals(EMAIL_TEXTO_SALVAR_SOMENTE_COPIA_OCULTA, body);
 	}
 
Index: devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/common/BaseTestCase.java
===================================================================
--- devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/common/BaseTestCase.java	(revision 4962)
+++ devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/common/BaseTestCase.java	(revision 5025)
@@ -82,5 +82,6 @@
 	@AfterSuite
 	public void afterSuite() {
-		driver.close();
+		// driver.close();
+		driver.quit();
 	}
 
Index: devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/calendar/compartilhar/PermitirAcessoSomenteLeituraEExclusaoAgendaTestCase.java
===================================================================
--- devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/calendar/compartilhar/PermitirAcessoSomenteLeituraEExclusaoAgendaTestCase.java	(revision 5025)
+++ devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/calendar/compartilhar/PermitirAcessoSomenteLeituraEExclusaoAgendaTestCase.java	(revision 5025)
@@ -0,0 +1,50 @@
+package org.expressolivre.cte.calendar.compartilhar;
+
+import org.expressolivre.cte.common.BaseCalendarTestCase;
+import org.expressolivre.cte.pages.calendar.AgendaAddACLUserPage;
+import org.expressolivre.cte.pages.calendar.AgendaPermissionPage;
+import org.testng.annotations.Parameters;
+import org.testng.annotations.Test;
+
+/**
+ * Suite:[FUN03.7] Compartilhar agenda
+ * 
+ * Caso de Teste: EL-979:Permitir acesso somente leitura e exclusao a agenda
+ * 
+ * Link: http://testlink.expressolivre.org/linkto.php?tprojectPrefix=EL&item=
+ * testcase&id=EL-979
+ * 
+ * @author L.F.Estivalet (Serpro)
+ * 
+ *         Created on Aug 23, 2011 at 3:25:24 PM
+ * 
+ */
+public class PermitirAcessoSomenteLeituraEExclusaoAgendaTestCase extends
+		BaseCalendarTestCase {
+
+	@Parameters({ "nomeUsuario", "organizacao", "setor" })
+	@Test
+	public void permitirAcessoSomenteLeituraEExclusaoAgenda(String nomeUsuario,
+			String organizacao, String setor) {
+		AgendaPermissionPage app = super.openAgendaPermissionPage();
+
+		// Se usuario nao estiver na lista de permissoes abrir popup para
+		// procurar e adicionar.
+		if (!app.isUserInList(nomeUsuario)) {
+			// TODO verificar essa implementacao pois, algumas vezes nao
+			// funciona...
+			AgendaAddACLUserPage aaaup = app.addUserACL();
+			aaaup.setOrganization(organizacao);
+			aaaup.setSector(setor);
+			aaaup.selectUser(nomeUsuario);
+			aaaup.addUser();
+			aaaup.close();
+		}
+
+		app.clearPemissions();
+		app.setReadPermission(true);
+		app.setRemovePermission(true);
+		app.apply();
+	}
+
+}
Index: devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/calendar/compartilhar/AdicionarCompromissoAgendaTestCase.java
===================================================================
--- devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/calendar/compartilhar/AdicionarCompromissoAgendaTestCase.java	(revision 5025)
+++ devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/calendar/compartilhar/AdicionarCompromissoAgendaTestCase.java	(revision 5025)
@@ -0,0 +1,81 @@
+package org.expressolivre.cte.calendar.compartilhar;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+
+import org.expressolivre.cte.common.BaseCalendarTestCase;
+import org.expressolivre.cte.common.Config;
+import org.expressolivre.cte.pages.calendar.AppointmentPage;
+import org.expressolivre.cte.pages.calendar.CalendarTodayViewPage;
+import org.testng.annotations.Optional;
+import org.testng.annotations.Parameters;
+import org.testng.annotations.Test;
+
+/**
+ * Suite:[FUN03.7] Compartilhar agenda
+ * 
+ * Caso de Teste: EL-985:Adicionar evento Ã  agenda compartilhada com permissÃ£o
+ * 
+ * Link: http://testlink.expressolivre.org/linkto.php?tprojectPrefix=EL&item=
+ * testcase&id=EL-985
+ * 
+ * @author L.F.Estivalet (Serpro)
+ * 
+ *         Created on Aug 24, 2011 at 2:52:19 PM
+ * 
+ */
+public class AdicionarCompromissoAgendaTestCase extends BaseCalendarTestCase {
+
+	@Parameters({ "owner", "tipo", "titulo", "descricao", "local",
+			"dataInicial", "horaInicial", "minutoInicial", "dataFinal",
+			"horaFinal", "minutoFinal", "prioridade" })
+	@Test
+	public void adicionarCompromissoAgendaCompartilhada(String owner,
+			@Optional("Normal") String tipo, String titulo,
+			@Optional("") String descricao, @Optional("") String local,
+			@Optional("") String dataInicial, String horaInicial,
+			String minutoInicial, @Optional("") String dataFinal,
+			String horaFinal, String minutoFinal,
+			@Optional("Normal") String prioridade) throws ParseException {
+		CalendarTodayViewPage ctvp = super.openTodayView();
+
+		// Busca o nome do usuario do arquivo de confirguracao.
+		String userName = Config.getInstance().getConfig(owner + ".name");
+		// Muda dono do compromisso.
+		ctvp.setOwner(userName);
+
+		Calendar cal = Calendar.getInstance();
+		SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
+		SimpleDateFormat sdf2 = new SimpleDateFormat("dd/MM/yyyy");
+
+		// Se a data inicial nao for informada, pega data corrente.
+		if ("".equals(dataInicial)) {
+			dataInicial = sdf2.format(cal.getTime());
+		}
+
+		// Se a data final nao for informada, pega data corrente.
+		if ("".equals(dataFinal)) {
+			dataFinal = sdf2.format(cal.getTime());
+		}
+
+		// Transforma a data inicial informada (dd/MM/yyyy) para (yyyyMMdd)
+		Date dtIni = sdf2.parse(dataInicial);
+
+		AppointmentPage ap = super.newAppointment(sdf.format(dtIni));
+		ap.setType(tipo);
+		ap.setTitle(titulo);
+		ap.setDescription(descricao);
+		ap.setLocation(local);
+		ap.setStartDate(dataInicial);
+		ap.setStartHour(horaInicial);
+		ap.setStartMinute(minutoInicial);
+		ap.setEndDate(dataFinal);
+		ap.setEndHour(horaFinal);
+		ap.setEndMinute(minutoFinal);
+		ap.setPriority(prioridade);
+		ap.saveAppointment();
+	}
+
+}
Index: devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/calendar/compartilhar/PermitirAcessoSomenteLeituraEEdicaoAgendaTestCase.java
===================================================================
--- devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/calendar/compartilhar/PermitirAcessoSomenteLeituraEEdicaoAgendaTestCase.java	(revision 5025)
+++ devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/calendar/compartilhar/PermitirAcessoSomenteLeituraEEdicaoAgendaTestCase.java	(revision 5025)
@@ -0,0 +1,50 @@
+package org.expressolivre.cte.calendar.compartilhar;
+
+import org.expressolivre.cte.common.BaseCalendarTestCase;
+import org.expressolivre.cte.pages.calendar.AgendaAddACLUserPage;
+import org.expressolivre.cte.pages.calendar.AgendaPermissionPage;
+import org.testng.annotations.Parameters;
+import org.testng.annotations.Test;
+
+/**
+ * Suite:[FUN03.7] Compartilhar agenda
+ * 
+ * Caso de Teste: EL-978:Permitir acesso somente leitura e edicao a agenda
+ * 
+ * Link: http://testlink.expressolivre.org/linkto.php?tprojectPrefix=EL&item=
+ * testcase&id=EL-978
+ * 
+ * @author L.F.Estivalet (Serpro)
+ * 
+ *         Created on Aug 23, 2011 at 10:20:24 AM
+ * 
+ */
+public class PermitirAcessoSomenteLeituraEEdicaoAgendaTestCase extends
+		BaseCalendarTestCase {
+
+	@Parameters({ "nomeUsuario", "organizacao", "setor" })
+	@Test
+	public void permitirAcessoSomenteLeituraAgenda(String nomeUsuario,
+			String organizacao, String setor) {
+		AgendaPermissionPage app = super.openAgendaPermissionPage();
+
+		// Se usuario nao estiver na lista de permissoes abrir popup para
+		// procurar e adicionar.
+		if (!app.isUserInList(nomeUsuario)) {
+			// TODO verificar essa implementacao pois, algumas vezes nao
+			// funciona...
+			AgendaAddACLUserPage aaaup = app.addUserACL();
+			aaaup.setOrganization(organizacao);
+			aaaup.setSector(setor);
+			aaaup.selectUser(nomeUsuario);
+			aaaup.addUser();
+			aaaup.close();
+		}
+
+		app.clearPemissions();
+		app.setReadPermission(true);
+		app.setEditPermission(true);
+		app.apply();
+	}
+
+}
Index: devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/calendar/compartilhar/ExcluirTodosUsuariosCompartilhamentoTestCase.java
===================================================================
--- devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/calendar/compartilhar/ExcluirTodosUsuariosCompartilhamentoTestCase.java	(revision 5025)
+++ devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/calendar/compartilhar/ExcluirTodosUsuariosCompartilhamentoTestCase.java	(revision 5025)
@@ -0,0 +1,30 @@
+package org.expressolivre.cte.calendar.compartilhar;
+
+import org.expressolivre.cte.common.BaseCalendarTestCase;
+import org.expressolivre.cte.pages.calendar.AgendaPermissionPage;
+import org.testng.annotations.Test;
+
+/**
+ * Suite:[FUN03.7] Compartilhar agenda
+ * 
+ * Caso de Teste: EL-987:Excluir todos UsuÃ¡rios com compartilhamento de agenda
+ * 
+ * Link: http://testlink.expressolivre.org/linkto.php?tprojectPrefix=EL&item=
+ * testcase&id=EL-987
+ * 
+ * @author L.F.Estivalet (Serpro)
+ * 
+ *         Created on Aug 25, 2011 at 2:08:24 PM
+ * 
+ */
+public class ExcluirTodosUsuariosCompartilhamentoTestCase extends
+		BaseCalendarTestCase {
+
+	@Test
+	public void excluirTodosUsuariosCompartilhamento() {
+		AgendaPermissionPage app = super.openAgendaPermissionPage();
+		app.removeAllUsers();
+		app.apply();
+	}
+
+}
Index: devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/calendar/compartilhar/PermitirAcessoSomenteLeituraAgendaTestCase.java
===================================================================
--- devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/calendar/compartilhar/PermitirAcessoSomenteLeituraAgendaTestCase.java	(revision 4962)
+++ devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/calendar/compartilhar/PermitirAcessoSomenteLeituraAgendaTestCase.java	(revision 5025)
@@ -29,13 +29,15 @@
 		AgendaPermissionPage app = super.openAgendaPermissionPage();
 
-		AgendaAddACLUserPage aaaup = app.addUserACL();
-		aaaup.setOrganization(organizacao);
-		aaaup.setSector(setor);
-		aaaup.selectUser(nomeUsuario);
-		aaaup.addUser();
-		aaaup.close();
-
-		app.setReadPermission();
-		app.cancel();
+		if (!app.isUserInList(nomeUsuario)) {
+			AgendaAddACLUserPage aaaup = app.addUserACL();
+			aaaup.setOrganization(organizacao);
+			aaaup.setSector(setor);
+			aaaup.selectUser(nomeUsuario);
+			aaaup.addUser();
+			aaaup.close();
+		}
+		app.clearPemissions();
+		app.setReadPermission(true);
+		app.apply();
 	}
 
Index: devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/calendar/compartilhar/EditarAgendaCompartilhadaSomenteLeituraEExclusaoTestCase.java
===================================================================
--- devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/calendar/compartilhar/EditarAgendaCompartilhadaSomenteLeituraEExclusaoTestCase.java	(revision 5025)
+++ devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/calendar/compartilhar/EditarAgendaCompartilhadaSomenteLeituraEExclusaoTestCase.java	(revision 5025)
@@ -0,0 +1,47 @@
+package org.expressolivre.cte.calendar.compartilhar;
+
+import org.expressolivre.cte.common.BaseCalendarTestCase;
+import org.expressolivre.cte.common.Config;
+import org.expressolivre.cte.pages.calendar.AppointmentViewPage;
+import org.expressolivre.cte.pages.calendar.CalendarTodayViewPage;
+import org.testng.Assert;
+import org.testng.annotations.Parameters;
+import org.testng.annotations.Test;
+
+/**
+ * Suite:[FUN03.7] Compartilhar agenda
+ * 
+ * Caso de Teste: EL-984:Editar agenda compartilhada com acesso somente leitura
+ * e exclusao
+ * 
+ * Link: http://testlink.expressolivre.org/linkto.php?tprojectPrefix=EL&item=
+ * testcase&id=EL-984
+ * 
+ * @author L.F.Estivalet (Serpro)
+ * 
+ *         Created on Aug 24, 2011 at 2:29:19 PM
+ * 
+ */
+public class EditarAgendaCompartilhadaSomenteLeituraEExclusaoTestCase extends
+		BaseCalendarTestCase {
+
+	@Parameters({ "owner", "titulo", "novaHoraInicio", "novoMinutoInicio",
+			"novaHoraFim", "novoMinutoFim" })
+	@Test
+	public void editarAgendaCompartilhadaSomenteLeituraEExclusao(String owner,
+			String titulo, String novaHoraInicio, String novoMinutoInicio,
+			String novaHoraFim, String novoMinutoFim) {
+		CalendarTodayViewPage ctvp = super.openTodayView();
+
+		// Busca o nome do usuario do arquivo de confirguracao.
+		String userName = Config.getInstance().getConfig(owner + ".name");
+		ctvp.setOwner(userName);
+
+		String id = ctvp.getAppointmentId(titulo);
+		AppointmentViewPage avp = cp.openAppointmentViewPage(id);
+		Assert.assertEquals(avp.getTitle(), titulo);
+
+		// Tenta remover o compromisso.
+		avp.removeAppointment();
+	}
+}
Index: devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/calendar/compartilhar/EditarAgendaCompartilhadaSomenteLeituraEEdicaoTestCase.java
===================================================================
--- devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/calendar/compartilhar/EditarAgendaCompartilhadaSomenteLeituraEEdicaoTestCase.java	(revision 5025)
+++ devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/calendar/compartilhar/EditarAgendaCompartilhadaSomenteLeituraEEdicaoTestCase.java	(revision 5025)
@@ -0,0 +1,53 @@
+package org.expressolivre.cte.calendar.compartilhar;
+
+import org.expressolivre.cte.common.BaseCalendarTestCase;
+import org.expressolivre.cte.common.Config;
+import org.expressolivre.cte.pages.calendar.AppointmentEditPage;
+import org.expressolivre.cte.pages.calendar.AppointmentViewPage;
+import org.expressolivre.cte.pages.calendar.CalendarTodayViewPage;
+import org.testng.Assert;
+import org.testng.annotations.Parameters;
+import org.testng.annotations.Test;
+
+/**
+ * Suite:[FUN03.7] Compartilhar agenda
+ * 
+ * Caso de Teste: EL-983:Editar agenda compartilhada com acesso somente leitura
+ * e edicao
+ * 
+ * Link: http://testlink.expressolivre.org/linkto.php?tprojectPrefix=EL&item=
+ * testcase&id=EL-983
+ * 
+ * @author L.F.Estivalet (Serpro)
+ * 
+ *         Created on Aug 23, 2011 at 2:20:19 PM
+ * 
+ */
+public class EditarAgendaCompartilhadaSomenteLeituraEEdicaoTestCase extends
+		BaseCalendarTestCase {
+
+	@Parameters({ "owner", "titulo", "novaHoraInicio", "novoMinutoInicio",
+			"novaHoraFim", "novoMinutoFim" })
+	@Test
+	public void editarAgendaCompartilhadaSomenteLeituraEEdicao(String owner,
+			String titulo, String novaHoraInicio, String novoMinutoInicio,
+			String novaHoraFim, String novoMinutoFim) {
+		CalendarTodayViewPage ctvp = super.openTodayView();
+
+		// Busca o nome do usuario do arquivo de confirguracao.
+		String userName = Config.getInstance().getConfig(owner + ".name");
+		ctvp.setOwner(userName);
+
+		String id = ctvp.getAppointmentId(titulo);
+		AppointmentViewPage avp = cp.openAppointmentViewPage(id);
+		Assert.assertEquals(avp.getTitle(), titulo);
+
+		AppointmentEditPage aep = avp.editAppointment();
+		aep.setStartHour(novaHoraInicio);
+		aep.setStartMinute(novoMinutoInicio);
+		aep.setEndHour(novaHoraFim);
+		aep.setEndMinute(novoMinutoFim);
+		aep.saveAppointment();
+
+	}
+}
Index: devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/calendar/compartilhar/PermitirAdicaoAgendaTestCase.java
===================================================================
--- devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/calendar/compartilhar/PermitirAdicaoAgendaTestCase.java	(revision 5025)
+++ devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/calendar/compartilhar/PermitirAdicaoAgendaTestCase.java	(revision 5025)
@@ -0,0 +1,43 @@
+package org.expressolivre.cte.calendar.compartilhar;
+
+import org.expressolivre.cte.common.BaseCalendarTestCase;
+import org.expressolivre.cte.pages.calendar.AgendaAddACLUserPage;
+import org.expressolivre.cte.pages.calendar.AgendaPermissionPage;
+import org.testng.annotations.Parameters;
+import org.testng.annotations.Test;
+
+/**
+ * Suite:[FUN03.7] Compartilhar agenda
+ * 
+ * Caso de Teste: EL-980:Permitir acesso adicao de evento a agenda
+ * 
+ * Link: http://testlink.expressolivre.org/linkto.php?tprojectPrefix=EL&item=
+ * testcase&id=EL-980
+ * 
+ * @author L.F.Estivalet (Serpro)
+ * 
+ *         Created on Aug 24, 2011 at 2:49:24 PM
+ * 
+ */
+public class PermitirAdicaoAgendaTestCase extends BaseCalendarTestCase {
+
+	@Parameters({ "nomeUsuario", "organizacao", "setor" })
+	@Test
+	public void permitirAcessoAdicao(String nomeUsuario, String organizacao,
+			String setor) {
+		AgendaPermissionPage app = super.openAgendaPermissionPage();
+
+		if (!app.isUserInList(nomeUsuario)) {
+			AgendaAddACLUserPage aaaup = app.addUserACL();
+			aaaup.setOrganization(organizacao);
+			aaaup.setSector(setor);
+			aaaup.selectUser(nomeUsuario);
+			aaaup.addUser();
+			aaaup.close();
+		}
+		app.clearPemissions();
+		app.setAddPermission(true);
+		app.apply();
+	}
+
+}
Index: devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/calendar/compartilhar/EditarAgendaCompartilhadaSomenteLeituraTestCase.java
===================================================================
--- devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/calendar/compartilhar/EditarAgendaCompartilhadaSomenteLeituraTestCase.java	(revision 5025)
+++ devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/calendar/compartilhar/EditarAgendaCompartilhadaSomenteLeituraTestCase.java	(revision 5025)
@@ -0,0 +1,42 @@
+package org.expressolivre.cte.calendar.compartilhar;
+
+import org.expressolivre.cte.common.BaseCalendarTestCase;
+import org.expressolivre.cte.common.Config;
+import org.expressolivre.cte.pages.calendar.AppointmentViewPage;
+import org.expressolivre.cte.pages.calendar.CalendarTodayViewPage;
+import org.testng.Assert;
+import org.testng.annotations.Parameters;
+import org.testng.annotations.Test;
+
+/**
+ * Suite:[FUN03.7] Compartilhar agenda
+ * 
+ * Caso de Teste: EL-982:Editar agenda compartilhada com acesso somente leitura
+ * 
+ * Link: http://testlink.expressolivre.org/linkto.php?tprojectPrefix=EL&item=
+ * testcase&id=EL-982
+ * 
+ * @author L.F.Estivalet (Serpro)
+ * 
+ *         Created on Aug 22, 2011 at 4:31:19 PM
+ * 
+ */
+public class EditarAgendaCompartilhadaSomenteLeituraTestCase extends
+		BaseCalendarTestCase {
+
+	@Parameters({ "owner", "titulo" })
+	@Test
+	public void editarAgendaCompartilhadaSomenteLeitura(String owner,
+			String titulo) {
+		CalendarTodayViewPage ctvp = super.openTodayView();
+
+		// Busca o nome do usuario do arquivo de confirguracao.
+		String userName = Config.getInstance().getConfig(owner + ".name");
+		ctvp.setOwner(userName);
+
+		String id = ctvp.getAppointmentId(titulo);
+		AppointmentViewPage avp = cp.openAppointmentViewPage(id);
+		Assert.assertEquals(avp.getTitle(), titulo);
+
+	}
+}
Index: devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/calendar/adicionar/AdicionarCompromissoDataFinalMenorDataInicialTestCase.java
===================================================================
--- devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/calendar/adicionar/AdicionarCompromissoDataFinalMenorDataInicialTestCase.java	(revision 4902)
+++ devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/calendar/adicionar/AdicionarCompromissoDataFinalMenorDataInicialTestCase.java	(revision 5025)
@@ -62,6 +62,6 @@
 		ap.saveAppointment();
 
-		Assert.assertEquals("VocÃª informou uma data invÃ¡lida.",
-				ap.getFormStatus());
+		Assert.assertEquals(ap.getFormStatus(),
+				"VocÃª informou uma data invÃ¡lida.");
 
 	}
Index: devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/calendar/adicionar/AdicionarCompromissoHoraFinalMenorHoraInicialTestCase.java
===================================================================
--- devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/calendar/adicionar/AdicionarCompromissoHoraFinalMenorHoraInicialTestCase.java	(revision 4902)
+++ devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/calendar/adicionar/AdicionarCompromissoHoraFinalMenorHoraInicialTestCase.java	(revision 5025)
@@ -58,6 +58,7 @@
 
 		Assert.assertEquals(
-				"A hora de inicio nÃ£o pode ser maior do que a hora de tÃ©rmino.",
-				ap.getFormStatus());
+
+		ap.getFormStatus(),
+				"A hora de inicio nÃ£o pode ser maior do que a hora de tÃ©rmino.");
 
 	}
Index: devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/calendar/adicionar/AdicionarCompromissoDataInicialFinalInvalidaTestCase.java
===================================================================
--- devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/calendar/adicionar/AdicionarCompromissoDataInicialFinalInvalidaTestCase.java	(revision 4902)
+++ devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/calendar/adicionar/AdicionarCompromissoDataInicialFinalInvalidaTestCase.java	(revision 5025)
@@ -58,6 +58,6 @@
 		ap.saveAppointment();
 
-		Assert.assertEquals("VocÃª informou uma data invÃ¡lida.",
-				ap.getFormStatus());
+		Assert.assertEquals(ap.getFormStatus(),
+				"VocÃª informou uma data invÃ¡lida.");
 
 	}
Index: devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/calendar/visualizar/AceitarCompromissoTestCase.java
===================================================================
--- devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/calendar/visualizar/AceitarCompromissoTestCase.java	(revision 4962)
+++ devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/calendar/visualizar/AceitarCompromissoTestCase.java	(revision 5025)
@@ -24,5 +24,6 @@
 	public void aceitarCompromisso(String titulo,
 
-	@Optional("") String dataInicial, String horaInicial, String minutoInicial) {
+	@Optional("") String dataInicial, String horaInicial, String minutoInicial)
+			throws Exception {
 
 		Calendar cal = Calendar.getInstance();
@@ -40,7 +41,13 @@
 		AppointmentEmailPage aep = mp.readAppointmentEmail(assunto);
 		AppointmentStatusPage asp = aep.accept(id);
-		Assert.assertEquals(asp.getMessage(),
-				"O compromisso foi aceito com sucesso!");
-		asp.close();
+		System.out.println("antes assert");
+		String message = asp.getMessage();
+
+		System.out.println("depois assert");
+		aep = asp.close();
+		// TODO espera um tempo ate a janela popup fechar. Rever essa
+		// implementacao pois o close acima nao esta funcionando como deveria.
+		// super.dummyWait(5);
+		Assert.assertEquals(message, "O compromisso foi aceito com sucesso!");
 	}
 }
Index: devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/calendar/visualizar/ExibirCompromissoTestCase.java
===================================================================
--- devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/calendar/visualizar/ExibirCompromissoTestCase.java	(revision 4965)
+++ devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/calendar/visualizar/ExibirCompromissoTestCase.java	(revision 5025)
@@ -53,4 +53,6 @@
 				avp.getAppointmentInfo(AppointmentViewPage.PRIORITY),
 				prioridade);
+
+		avp.ready();
 	}
 }
Index: devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/calendar/visualizar/MarcarTentativaCompromissoTestCase.java
===================================================================
--- devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/calendar/visualizar/MarcarTentativaCompromissoTestCase.java	(revision 4962)
+++ devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/calendar/visualizar/MarcarTentativaCompromissoTestCase.java	(revision 5025)
@@ -42,11 +42,10 @@
 		AppointmentEmailPage aep = mp.readAppointmentEmail(assunto);
 		AppointmentStatusPage asp = aep.tentative(id);
-		Assert.assertEquals(asp.getMessage(),
-				"O compromisso foi aceito com sucesso!");
+		String message = asp.getMessage();
 		aep = asp.close();
 
 		// TODO espera um tempo ate a janela popup fechar. Rever essa
 		// implementacao pois o close acima nao esta funcionando como deveria.
-		super.dummyWait(5);
+		// super.dummyWait(10);
 
 		AppointmentViewPage avp = aep.viewAppointment(id);
@@ -54,4 +53,5 @@
 				.getAppointmentInfo(AppointmentViewPage.PARTICIPANTS));
 
+		Assert.assertEquals(message, "O compromisso foi aceito com sucesso!");
 	}
 }
Index: devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/calendar/visualizar/RejeitarCompromissoTestCase.java
===================================================================
--- devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/calendar/visualizar/RejeitarCompromissoTestCase.java	(revision 4962)
+++ devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/calendar/visualizar/RejeitarCompromissoTestCase.java	(revision 5025)
@@ -42,15 +42,17 @@
 		AppointmentEmailPage aep = mp.readAppointmentEmail(assunto);
 		AppointmentStatusPage asp = aep.reject(id);
-		Assert.assertEquals(asp.getMessage(),
-				"O compromisso foi rejeitado com sucesso!");
+		String message = asp.getMessage();
 		aep = asp.close();
 
 		// TODO espera um tempo ate a janela popup fechar. Rever essa
 		// implementacao pois o close acima nao esta funcionando como deveria.
-		super.dummyWait(5);
+		// super.dummyWait(10);
 
 		AppointmentViewPage avp = aep.viewAppointment(id);
 		System.out.println(avp
 				.getAppointmentInfo(AppointmentViewPage.PARTICIPANTS));
+
+		Assert.assertEquals(message, "O compromisso foi rejeitado com sucesso!");
+
 	}
 }
Index: devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/calendar/visualizar/EditarCompromissoRecorrente1OcorrenciaTestCase.java
===================================================================
--- devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/calendar/visualizar/EditarCompromissoRecorrente1OcorrenciaTestCase.java	(revision 4917)
+++ devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/calendar/visualizar/EditarCompromissoRecorrente1OcorrenciaTestCase.java	(revision 5025)
@@ -47,4 +47,5 @@
 
 		AppointmentEditPage aep = avp.editAppointment();
+		aep.setTitle(novoTitulo);
 		aep.setLocation(novoLocal);
 		aep.setStartHour(novaHoraInicial);
